📅 2018-Aug-31 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ diff, merge, vim, vimdiff ⬩ 📚 Archive
Vim can be used as a diff and merge tool. While it cannot match the beauty and power of GUI programs like Meld, it is immensely useful to diff and merge over a SSH session.
vim -d
or as vimdiff
. Just pass in the names of the files to compare:$ vimdiff 1.cpp 2.cpp
$ vim -d 1.cpp 2.cpp 3.cpp
Vim in diff mode displays each file in its own window side-by-side showing the diff sections in colors. You can switch between the windows using the normal Vim commands. (I use Ctrl-W-W
.) And when you scroll down all the windows scroll down with you because they are locked to each other.
To switch to and fro between diffs use the ]-c
and [-c
commands.
To put the diff the cursor is resting on to the next window use the command dp
To pull the diff from the next window use the command do
Tried with: Vim 7.4 and Ubuntu 16.04