Is there a way we can exclude the lines which are same in the below output? I did a vim -d file1 file2 but its showing the differences and also some additions lines before and after the differences. How to exclude that?

In the attached example 131, 132, 134, 136 etc are same in both the files but its still getting displayed.

enter image description here


Add to your .vimrc:

set diffopt=filler,context:0

This will tell vimdiff (or if you prefer, vim -d) to not provide the full context for the lines in which differences were found. Consecutive lines with no changes will be "folded".

  • 2
    You can also set these options temporarily via the command line if you don't want to keep them permanently in your .vimrc. Simply use Vim's -c command line option: vimdiff -c 'set diffopt=filler,context:0' file1 file2. – Florian Brucker Dec 5 '18 at 15:19
  • You can also change it after opening vimdiff with :set diffopt=filler,context:0 – wisbucky Aug 29 at 22:00

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.