Vim - Search and replace the results

后端 未结 4 715
刺人心
刺人心 2021-02-13 05:13

I\'m getting more and more comfortable with Vim after a few months. BUT, there is only one simple feature I can\'t get any answer from the web. That is \"Search and replace the

4条回答
  •  难免孤独
    2021-02-13 06:02

    If you've already done a search you can do a substitution for the same pattern by simply leaving out the pattern in the substitute command. eg:

    /keyword
    

    searchs for "keyword", and then:

    :%s//new_keyword/g
    

    will replace all occurrences of "keyword" with "new_keyword".

提交回复
热议问题