[英]Is there a vim command that swap two words with crossing one operator?
[英]Vim replace two words with one another
如何在vim中用'bar'和'bar'替換'foo'的所有'foo'實例?
看看這個: 如何只編寫一個模式來在vim中以雙向方式交換兩個字符串
:s/foo\|bar/\={'foo':'bar','bar':'foo'}[submatch(0)]/g
除了使用臨時單詞進行更改之外,您還可以使用這樣的廢除插件:
:%SubVert/{foo,bar}/{bar,foo}/g
它必須以最聰明的方式存在,但這個肯定會起作用!
你可以用臨時詞來做。 請確保它在當前文檔中不存在。
/\<asd123\>
:%s/\<foo\>/asd123/g
:%s/\<asd123\>/bar/g
:%s/\<bar\>/foo/g
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.