Conditional replace in vim

后端 未结 5 690
渐次进展
渐次进展 2021-01-05 01:10

I\'d like do use vim search-and-replace to replace all \" with \' and vice-versa. Is there a way to achieve this in one step? I\'m thinking of something like this:

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-05 01:22

    You can do so easily by using the abolish.vim plugin.

    Abolish.vim has a :Subvert command which gives you a different approach to searching and replacing in its own little DSL.

    :%S/{\",'}/{',\"}/g
    

    This plugin has received the special honour of having a three-part screencast on Vimcasts.org dedicated to it: one, two, three.

提交回复
热议问题