Tuesday, October 19, 2010

diff this!

Found a cool VIM's command - :diffthis. Invoking it in two different buffers tells the editor to diff the buffers as if it was started as vimdiff. Best (most interesting to me) part is that one can diff two unsaved buffers. E.g.:

" split the screen vertically
" paste first code fragment into the left buffer and
" press ^W^W to switch to the right buffer, paste the second code fragment and again call

To cancel the effect of :diffthis one uses the :diffoff command. The command is too buffer specific and has to be invoked in both buffers.

Another interesting related command is :diffpatch {diff-file} which again invokes vimdiff diffing the file currently in buffer against the file with the patch applied.

1 comment:

Chuggy said...

in case some one finds this via search like I just did...

:windo diffthis

to trigger it in all visible windows at once. then:


to cancel it.