VIM find and replace whole word starting with dollar

How can I search and replace whole words starting with a dollar sign ($) in VIM?

I know it \<word\>

matches the whole word and \$

does a dollar sign for regular search and replace, but using \<\$word\>

or \$word\>

only results in "E486: pattern not found"

+3


source to share


1 answer


This is easily explained. $

is usually not a keyword character, so a statement that \<

provides ("match at the beginning of [keyword]" cannot be met.

You can add $

(for the current buffer) via



:setlocal iskeyword+=$

      

but it also affects movement and may even break syntax highlighting. Better to just drop the regex assertion; \$word\>

should be enough. If you need to assert that there are only spaces before it:\S\@<!\$word\>

+5


source







All Articles