Low Orbit Flux Logo 2 F

Linux Command - Vimdiff

The Linux vimdiff command is basically a wrapper for vim. It opens up between 2 to 8 files with vim and shows the differences.

Diff two files:



vimdiff hello.js hello2.js

Same thing but without the wrapper:



vim –d hello.js hello2.js

Diff three files:



vimdiff hello.js hello2.js hello3.js

Switch to diff mode while already using vim to edit a single file ( horizontal or vertical ):



:diffsplit hello2.js
:vert diffsplit hello2.js

Commands:

]c Jump to the next diff
[c Jump to the previous diff
ctrl +w h switch one window to the left
ctrl +w l switch one window to the right
dp copy highlighted diff to other window
do copy highlighted diff from other windows
:diffput copy highlighted diff to other window
:diffget copy highlighted diff from other windows
za toggle current code fold