Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vimdiff - How to hide all same lines in both files and show only different ones

Tags:

vim

vimdiff

vimdiff file1 file2

besides differences shows also same lines from both files. Is it possible to hide them? How to do it?

like image 406
LookAheadAtYourTypes Avatar asked Nov 24 '17 10:11

LookAheadAtYourTypes


People also ask

How do you get to the next difference in Vimdiff?

Switch between diff window Please note that, we have to press Ctrl + w 2 times.

How do you expand lines in Vimdiff?

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)

What is Vimdiff?

What is vimdiff? Vimdiff is a Linux command that can edit two, three, or four versions of a file with Vim and show their differences.


1 Answers

As Vim is a text editor (not a specialized diff viewer), the full contents of both files are kept (so you can do edits and persist them). Vim usually just "hides" multiple identical lines by folding them away; they are still present, just not visible.

You can influence how many identical lines are kept around changes (default: 6 lines above and below) via the context value of the 'diffopt' option. So, to completely fold all identical lines:

:set diffopt+=context:0
like image 59
Ingo Karkat Avatar answered Oct 04 '22 05:10

Ingo Karkat