Closed sushengloong closed 9 years ago
@sushengloong This is caused by set gdefault
in general_config.vim. If you were to do :%s/foo/bar
instead, the correct behaviour is expected. Putting an additional g
flag with gdefault
turned on, will cause it to substitute only one.
From :help gdefault
:
When on, the ":substitute" flag 'g' is default on. This means that all matches in a line are substituted instead of one. When a 'g' flag is given to a ":substitute" command, this will toggle the substitution of all or one match.
Hope this helps!
Sorry, I didn't know about gdefault. Thanks @alanyjw for explaining.
My environment
Steps to reproduce:
foo foo
:%s/foo/bar/g
bar foo
- only the firstfoo
is substituted.However, when I launched
vim -u NONE
and did the steps above, bothfoo
's were replaced withbar
successfully. Appreciate if anyone could help verify and fix this. Thanks.