When comparing files, and updating a source code repository, I like to use vimdiff. To copy changes made from one file to the other, I usually use a key sequence like this:-
Shift + V (select line)
k or j; { or }; Up or down arrow keys (select more lines)
y (copy selected lines)
Ctrl + w, left/right arrow (move to other pane)
p (paste lines)
Vim, being the master of keyboard shortcuts, should surely have an easier way of performing this same task. Is there one? What do you use to manually update source-code changes?
Best Answer
do
(diff obtain) anddp
(diff put) is what you need. Here is a small list of other helpful normal mode commands in this context.NOTE:
Both
do
anddp
work if you are on a block or just one line under a block in normal mode but not in visual mode. When selecting lines of text in visual mode, you must use the normal commands:'<,'>diffget
and:'<,'>diffput
.See also
:h copy-diffs
.:diffupdate
will re-scan the files for changes.