Globally append to line with matching term in vim

后端 未结 3 862
萌比男神i
萌比男神i 2021-02-04 04:50

I am sure this is easy, I am just missing a character or two.

I need to search for a particular term in a file, and when I find it, I need to append something to that

3条回答
  •  梦如初夏
    2021-02-04 05:18

    :%s/green/bright &/g: Replace each "green" with "bright green" in the file.

    &: substitute matched string. You can do anything you can imagine.

    You can use the flag \v so we don't have to use as many escape characters.

    append the parameter --no-startup-id after exec or exec_always

    :%s/exec\(_always\)\?/& --no-startup-id/g

    simplify it:

    :%s/\vexec(_always)?/& --no-startup-id/g

提交回复
热议问题