如何在vim中替换括号

Jog*_*usa 32 regex vim

在Vim我有:

simulación (fig.),pretexto (fig.),excusa (fig.).
Run Code Online (Sandbox Code Playgroud)

我的目标是:

simulación ,pretexto ,excusa .
Run Code Online (Sandbox Code Playgroud)

我尝试过::%s/\(fig\.\)//g,但它不起作用.

DrA*_*rAl 54

默认情况下,Vim不需要转义括号.尝试:

:%s/(fig\.)//g
Run Code Online (Sandbox Code Playgroud)

看到:

:help magic
Run Code Online (Sandbox Code Playgroud)

编辑

添加反斜杠转义点.


wil*_*ler 7

不要逃避parens - vim默认使用"魔术"转义方案.尝试:

:%s/(fig\.)//g
Run Code Online (Sandbox Code Playgroud)

更多信息:http://vimdoc.sourceforge.net/htmldoc/pattern.html#/\v

  • 如果你没有逃脱这一点,这也将匹配(figx)(见我和Adriano的编辑:我们都这样做了!). (2认同)