Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Vim, how do I match on "=" but not on "=="?

Tags:

regex

vim

I've tried a number of different search patterns:

  • [^=]=[^=] works but only if = is not at the beginning/end and it also matches the sandwiching characters
  • =\@!==\@! seems like it should work because \@! matches nothing but requires a match, but it doesn't (see :help pattern-overview)
  • [^=]\@==[^=]\@= also doesn't but seems like it should

Suggestions?

like image 474
me2 Avatar asked Feb 23 '10 22:02

me2


People also ask

How do I match a pattern in Vim?

In normal mode, press / to start a search, then type the pattern ( \<i\> ), then press Enter. If you have an example of the word you want to find on screen, you do not need to enter a search pattern. Simply move the cursor anywhere within the word, then press * to search for the next occurrence of that whole word.

What does F do in Vim?

The f command is very similar to the t command, but it places your cursor on top of the character. The F command works how you might expect, moving your cursor backwards and on top of the next occurrence of the selected character.

Does vim support regex?

Vim has several regex modes, one of which is very magic that's very similar to traditional regex. Just put \v in the front and you won't have to escape as much.


1 Answers

Ah hah: =\@<!==\@!

like image 98
me2 Avatar answered Nov 05 '22 07:11

me2