VIM S& R - 在搜索模式中使用backref

时间:2017-05-28 14:57:43

标签: regex vim

我想搜索并替换这样的内容:

document.addEventListener('keyup', function (e) { if (evtesc.keyCode === 27) { document.getElementById("search-largeinput").value = ""; } };

"foo : foo"

但当然,我需要一个正则表达式。

我尝试使用下面的S& R命令,但似乎在搜索到的字符串中使用backref不起作用:

 "foo"

知道我该怎么做?

感谢。

1 个答案:

答案 0 :(得分:2)

%s/\([a-z]\+\)\zs : \1\ze//

[a-z]表示“任何字符”,\+表示“重复1次以上”。

\ 1完美无缺!