Reputation: 184
How to search for **
in a file using vim like **kwargs
, when I use a /**
it highlights the entire file.
Upvotes: 0
Views: 1004
Reputation: 196546
*
is a meta-character that needs to be escaped to become a regular character:
/\*\*
Vim refers to this as "magic": if the pattern is "magic", you need to escape meta-characters, if it is "nomagic", you don't (this is a bit over-simplified, see :help magic
).
Therefore, you can force Vim to treat the pattern as "nomagic" with \M
or even "very nomagic", with \V
:
/\V**
Which doesn't help much, here, but well…
As for why /**
highlights the whole buffer, a hint can be found under :help /star
:
Exception: When "*" is used at the start of the pattern or just after
"^" it matches the star character.
*
matches (at least some of) the stars in your buffer,*
matches zero or more of the preceding atom, as many as possible, so, essentially, every character.Upvotes: 3
Reputation: 179
You have to escape the * symbol, try
/\*\*
On the text below I added extra spaces to be easier to read
#Don't use this one
/ \* \*
Upvotes: 1