In Vim how can I search and replace every other match?

后端 未结 7 1268
Happy的楠姐
Happy的楠姐 2020-12-23 23:41

Say I have the following file


    
    


    

        
7条回答
  •  执笔经年
    2020-12-24 00:18

    I'd do it with a macro:

    qv            start recording in register v
    /"bar"/e  search for "bar" and position the cursor at the end of the match
    i1       insert 1 before the cursor and go back to normal mode
    n             jump to next match
    q             stop recording
    

    After that, do {count}@v.

提交回复
热议问题