How can you have vimdiff show the entire contents of the files being differenced? I'd like the color highlights of the differences, but would still like to see the entire files, i.e. the parts that are identical as well.


vimdiff sets foldmethod diff so all unchanged lines are folded. From inside vimdiff you can open all folds by pressing zR.

If you would like to always show the full context you could increase the number of unfolded context lines shown to some large number. In your ~/.vimrc:

if &diff                             " only for diff mode/vimdiff
  set diffopt=filler,context:1000000 " filler is default and inserts empty lines for sync
  • 7
    Yes, zR is the way to go. Note: za will recreate the folds. – sleske Oct 12 '10 at 21:07
  • @sleske za doesn't close but zM does, as evident from @Thomas 's answer. – MycrofD Jun 10 '18 at 13:51
  • @MycrofD: Yes. To be precise: za will close a single fold (the one under the cursor); zM will close all folds. Both can be useful. – sleske Jun 10 '18 at 18:55
  • Is there any option to increase unfolded context lines in the vimdiff command itself. This will be useful while running from shell script file. – itsraja May 10 '19 at 10:32
  • Yes, there is see, vimdoc.sourceforge.net/htmldoc/options.html#'diffopt', e.g., to view with 42 lines of context one could set set diffopt+=context:42. – Benjamin Bannier May 12 '19 at 7:38

This answer to the question on stackoverflow is worth checking.

Vimdiff: What are the most frequently used commands/shortcuts that could get a newbie started?

in a nutshell: zo and zc to respectively open and close a section zM and zR to respectively expand and fold all the sections


Placing the cursor on the line you want to expand and hitting the space bar works for me!

It seems like I've had to use the arrow keys sometimes too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.