从一个窗口移动到另一个窗口

时间:2009-03-27 04:54:25

标签: vim

是否有一个简单的命令可以将行从一个窗口移动到另一个窗口。目前我去一个窗口,拉线,然后粘贴到另一个窗口。

我想知道我是否可以在不切换窗口的情况下做到这一点。

4 个答案:

答案 0 :(得分:8)

我会用宏来做这件事。所以要记录a,qa的宏。然后yy拉线,:bnext切换缓冲区,p粘贴线,然后再次bnext切换回原始缓冲区(在你开始的线上)。然后点击q停止录制。

所以要复制,切换窗口,粘贴然后切换回来,你只需要使用@a。或者将其映射到功能键(map @a)。

N.B。只是在注释中注意到你有多个缓冲区,所以很明显你需要相应地记录你的宏。

答案 1 :(得分:1)

使用vimdiff可以使用diffput或diffget复制缓冲区之间的更改。从手册:

There are two commands to copy text from one buffer to another.  The result is
that the buffers will be equal within the specified range.


                        *:diffg* *:diffget*
:[range]diffg[et] [bufspec]
    Modify the current buffer to undo difference with another
    buffer.  If [bufspec] is given, that buffer is used.
    Otherwise this only works if there is one other buffer in diff
    mode.
    See below for [range].


                        *:diffpu* *:diffput*
:[range]diffpu[t] [bufspec]
    Modify another buffer to undo difference with the current
    buffer.  Just like ":diffget" but the other buffer is modified
    instead of the current one.
    See below for [range].

答案 2 :(得分:1)

你可以尝试这种映射:

nmap <C-y> Y<C-w>wp<C-w>w

答案 3 :(得分:0)

我怀疑这是否可行。但是这里有一篇有趣的帖子about 100 Vim commands每个程序员都应该知道你是否感兴趣。