-
-
Notifications
You must be signed in to change notification settings - Fork 2
13.2. vimdiff two files
vimdiff file1 file2
vim -d file1 file2
In vim:
:vert diffsplit file2
To open the diff in a new tab in the existing window:
vim --remote-tab-silent -c "vert diffsplit [file2]" [file1]
To get both files scrolling at the same time, add this to .vimrc
set scrollbind
If you loose the diff for whatever reason (e.g. I lost the diff when opening a new tab with :tabnew), turn the diff option on again.
:set diff
You'll also need to redo the diff if you make a non-trivial change to a line, in which case run the following:
:diffupdate
Switch viewport:
ctrl-w w
Jump to next diff:
]c
Jump to previous diff:
[c
Whole diff
To replace a diff in the current viewport with that from the other viewport, use the :diffget command. This can be shortened to the following:
do
To replace a diff in the other viewport with that from the current viewport, use the :diffput command. This can be shortened to the following:
dp
If you want to get contents from the other viewport when the current viewport has "filler" - i.e. a series of dashes - then do so from the line below.
To replace just a single line or multiple lines in a diff in the current viewport (rather than getting the entire diff), use a range. You have to use the full command for this - you can't use the shortened command shown above. For example, if you want to get line 63 from the other viewport, do the following:
:63diffget
By 'ctrl+w' to change the viewport and use :5diffget
The diffget command can be shortened slightly to diffg.
It's similar for diffput.
Important: The Tables of Content are generated. Any change will be overridden on the next update.
For more information: GitHub Wikifier