let splitted = split(out,'\n') if line('$') > len(splitted) execute len(splitted) .',$delete' endif call setline(1,splitted)
(详细:https://github.com/fatih/vim-go/blob/master/autoload/go/fmt.vim#L130)
但是setline()会导致某些机器和07001的速度变慢.我自己对它进行了描述,但对我而言,setline不是问题.无论如何,我需要一个更快的解决方案.所以我想出了其他几个解决方案.
第一个是将输出放到寄存器中,删除所有行然后将其放回:
let @a = out % delete _ put! a $delete _
第二个解决方案是使用append()(之前在vim-go https://github.com/fatih/vim-go/commit/99a1732e40e3f064300d544eebd4153dbc3c60c7中使用过):
let splitted = split(out,'\n') %delete _ call append(0,splitted) $delete _
他们都工作!然而,它们都会引起副作用,我仍然无法解决,也写在标题中.问题描述如下:
If a buffer is opened in another view (say next to next),and
we call one of the two solutions above,it breaks the cursor of
the other view and jumps to the bottom
这是一个GIF显示它更好(每当我打电话:w上面的一个程序被调用):http://d.pr/i/1buDZ
有没有办法,替换缓冲区的内容,这是快速的,不会打破布局?或者我如何使用上述程序之一阻止它?
谢谢.
:let old_view=winsaveview() :% delete _ :put! =out :$delete _ :call winrestview(old_view)
但是我对以更快的方式粘贴文本一无所知
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。