So you know that /
will bring up search in Vim and VSCode Vim. That's good!
But then you named a variable is
and now want to find every occurence of that word - but only where it stands alone. So no places where it occurs as part of your isLargePizza()
function for example.
Luckily, that's doable: \<
matches the beginning of a word and \>
the end.
So hitting ...
/\<is\>
... will to the trick!
Edit:
See this comment by @pbnj for additional tips relating to word boundary search.
Oldest comments (3)
Nice.
See
:help #
and:help *
for additional related features.For example:
#
, vim will perform the same bounded word search going backward. Equivalent to?\<word\>
.*
, vim will perform the same bounded word search going forward. Equivalent to/\<word\>
.This can be combined with other ways of searching in vim. For example:
:vimgrep /\<word\>/ %
will perform bounded search for all instances ofword
and load the results in:help quickfix-window
. From there, you can navigate through the results with:copen
,:cnext
,:cprev
, to open the list, go to next result, or go to previous result respectively.These are great tips, thanks!
I added a reference to your comment to the end of the post.