To find lines which have “This” and “NotThat” it is as simple as:
Let’s dive into each piece of this in a little more detail…
The :g is a way to list out all matches in a file. For instance to see all lines listed out which match “This” you could use:
Furthermore, if you wanted lines that contained both “This” and “That” then you could use:
The reason why the .* is needed is that it looks for the conjoined match (the ampersand) from the previous match. You will notice that the highlighting/match will select the range, i.e.
we use brackets to show the match from [This to That] nothing else matches
By adding the \@! we tell vim to negate that term and viola we are search for “This” and not “That” e.g.
Would match the second line, but not the first:
we use brackets to show the match from This to That nothing else matches on this line we only have This and thus it will match
Notice that only the second line will match.