Can I substitute multiple items in a single regular expression in VIM or Perl?

后端 未结 7 1447
情歌与酒
情歌与酒 2020-12-02 15:57

Let\'s say I have string \"The quick brown fox jumps over the lazy dog\" can I change this to \"The slow brown fox jumps over the energetic dog\" with one regular expression

7条回答
  •  旧巷少年郎
    2020-12-02 16:29

    You can concatenate vim substitutions:

    The quick brown fox ran quickly next to the lazy brook.

    :s/quick/slow/|s/lazy/energetic/
    

    The slow brown fox ran quickly next to the energetic brook.

    The advantage here is that you have to type your substitutions just once

    Rgds

提交回复
热议问题