I've started using vimdiff today, and wanted to do some of the things that I've taken for granted on Windows based diff editors (like expand/collapse a diff section, have full file expansion/only diffs with 3 context lines above or below, etc.). I currently know only the following commands :
Keyboard Shortcuts:
do - Get changes from other window into the current window.
dp - Put the changes from current window into the other window.
]c - Jump to the next change.
[c - Jump to the previous change.
CTRL+W, w - Switch to the other split window (CTRL+W, CTRL+W does the same thing, in case you let go of the CTRL key a bit later)
Could someone point me to the right direction so I could replicate similar features?
It would be nice if I could expand/collapse lines around the diffs, for example.
Aside from the ones you mention, I only use frequently when diffing the following:
:diffupdate
:diffu
-> recalculate the diff, useful when after making several changes vim's isn't showing minimal changes anymore. Note that it only works if the files have been modified inside vimdiff. Otherwise, use:
:e
to reload the files if they have been modified outside of vimdiff. :set noscrollbind
-> temporarily disable simultaneous scrolling on both buffers, reenable by :set scrollbind
and scrolling.Most of what you asked for is folding: vim user manual's chapter on folding. Outside of diffs I sometime use:
zo
-> open fold.zc
-> close fold.But you'll probably be better served by:
zr
-> reducing folding level.zm
-> one more folding level, please.or even:
zR
-> Reduce completely the folding, I said!.zM
-> fold Most!.The other thing you asked for, use n lines of folding, can be found at the vim reference manual section on options, via the section on diff:
set diffopt=<TAB>
, then update or add context:n
.You should also take a look at the user manual section on diff.