vimdiff
Yesterday I was looking at merging review edits in a LaTeX document. I decided
that I would use vimdiff
, which meant learning the keybindings (again, for
maybe the fifth or sixth time).
It’s pretty easy to use vimdiff
once you get the hang of it. Open two files
like:
vimdiff file1.tex file2.tex
You navigate between the two windows just like any other split in vim: Ctrl-w followed by h or l (to move left or right). Then you can navigate the documents and merge things:
]c : - next difference
[c : - previous difference
do - diff obtain (merge the diff from the other window)
dp - diff put (merge the diff to the other window)
zo - open folded text
zc - close folded text
:diffupdate - re-scan the files for differences
If you’re using a colorscheme that vimdiff looks awful in, the following could
help in your .vimrc
(this works great for me using Solarized):
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
If you would like to contact me with comments, please send me an email.
If you would like to support my free software work, you can support me on Patreon or donate via PayPal.