Sometimes my global substitutions don't substitute all matches in a line. It is confirmed by the fact that I can see it when I do substitutions with confirmation, a match is found in a line with multiple possible matches, but then it goes to another line.
I use the g
or gc
parameters operating on the entire file with %
.
On this file:
hello hello
hello
hello hello hello
hello
If I do %s/hello/goodbye/g
I get:
goodbye hello
goodbye
goodbye hello hello
goodbye
All I have in my .vimrc
about search/replace is:
set hlsearch
set ignorecase
set incsearch
vimrc
.:echo &gd
and what happens if you add a 2ndg
flag like this:%s/hello/goodbye/gg
or if you remove theg
flag entirely? If the output of:echo &gd
is1
, try addingset nogdefault
at the end of yourvimrc
.set nogdefault
like you said and it works now, by the way. Thank you!