To append a match efficiently in Vim :g/---/s/---/X/

后端 未结 2 1095
闹比i
闹比i 2021-02-04 12:35

How can you refer to the match in the command g in Vim?

I would like to put X after the match without replacing the match. For instance, in

相关标签:
2条回答
  • 2021-02-04 13:38

    I'm not sure why you need the g portion of the command - the substitute will only act on matching lines. Here's what you're looking for:

    :%s/create_title/&X/
    

    The & represents the entire text which was matched.

    0 讨论(0)
  • 2021-02-04 13:39
    :%s/\(create_title\)/\1X/g
    

    works for me. (if I understand your question correctly).

    0 讨论(0)
提交回复
热议问题