Vim全球替换(线)

yaw*_*ark 6 vim

"全局"选项不能按预期工作(这似乎最近才改变,但我无法找出差异的原因).

鉴于这条线:

ABA

我发出命令:

:S/A //克

我希望结果如下:

b

但是,生成的行是:

BA

我错过了什么?

Ran*_*ris 21

你很可能已经gdefault在你的.vimrc.

来自: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.
Run Code Online (Sandbox Code Playgroud)

如果您没有在配置中设置它,您可以通过发布来查看它的设置位置:verbose set gdefault?.