Vim 全局替换(行) [英] Vim global replace (line)

查看:22
本文介绍了Vim 全局替换(行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全局"选项没有按预期工作(这似乎只是最近才发生变化,但我还无法找出造成差异的原因).

The "global" option does not work as expected (this seems to have changed only recently, but I'm not able to track down the reason for the difference yet).

给定这条线:

aba

我发出命令:

:s/a//g

我希望结果是:

b

然而,结果行是:

ba

我错过了什么?

推荐答案

您很可能在 .vimrc 中设置了 gdefault.

You most likely have gdefault set in your .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.

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

If you are not setting this in your config you can see where it is set by issuing :verbose set gdefault?.

这篇关于Vim 全局替换(行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆