I\'ve been making a lot of changes to my .vimrc
lately, and somewhere along the line I\'ve introduced an undesirable feature. When performing a substitution com
The substitute command accepts the switch g
, for global, which causes the substitution to be made on all matches on the line:
:s/regex/replacement/g
The default is that only the first occurrence of the match is substituted, but there's a setting to switch the default to global: gdefault
. So set gdefault
in your vimrc if you want this as the default behavior. Try it out first in the current vim session with :set gdefault
.
Note that when you set gdefault
, this not only makes g
the default behavior, but it changes the usage of the g
flag so that using /g
at the end of a substitute will cause the substitution to be made only once.
See: :help gdefault
.