tags:

views:

299

answers:

4

Is there a simple command that will move lines from one window to another. Currently I go to one window, yank the lines, and then paste in the other window.

I would like to know if I can do it without switching windows.

+1  A: 

I doubt whether this is possible. But here is an interesting post about 100 Vim commands every programmer should know if you are interested.

Shoban
Thanks for the super useful link!
Dragos Toader
+4  A: 

I would do this sort of thing with a macro. So to record a macro for a, qa. Then yy to yank the line, :bnext to switch buffers, p to paste the line, then bnext again to switch back to the original buffer (on the line you started on). Then hit q to stop recording.

So to copy, switch windows, paste then switch back, you just need to use @a. Or map it to a function key (map @a).

N.B. Just noticed in the comments you had multiple buffers, so obviously you would need to record your macro accordingly.

Cannonade
I guess, thats what I might have to do. Use macros or write a script.
Bongali Babu
I find it is pretty seamless doing it this way. Vim macros are your friend ;).
Cannonade
+1  A: 

using vimdiff you can use diffput or diffget to copy changes between buffers. From the manual:

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].
vezult
I'm learning vimdiff (I've used Beyond Compare to merge in Windows) and vimdiff happens to be a great tool for merging.No programming, on the fly merging. I don't want to write a script for this sort of thing. Learning a few vi commands is notvery painful.
Dragos Toader
+1  A: 

You could try this mapping:

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