Some modes treat underscores as word boundaries.
I am using evil
via spacemacs
. I am trying to use a vim/sed style :%s/foo/bar/g
search and replace, but operate only on whitespace delimited words, not underscores.
As an example, if I have the following:
num_foos_
foos_
and I want to rename only foos_
to bars_
.
I have tried the following:
:%s/foos_/bars_/g
: matches bothnum_foos_
andfoos_
:%s/\bfoos_/bars_/g
: matches bothnum_foos_
andfoos_
(I guess because_
is a word boundary, so\b
matchesnum_foos_
):%s/\bfoos_\b/bars_/g
: matches neither (I guess because_
is a word boundary, and there is no word after the trailing_
):%s/\<foos_/bars_/g
: matches bothnum_foos_
andfoos_
(I guess for the same reasons as\b
)
How can I match only foos_
and not num_foos_
?