Match parenthesised block using regular expressions in vim

后端 未结 4 620
终归单人心
终归单人心 2020-12-03 22:14

I\'m trying to match the contents that belong between a certain ( and its matching ) as found by vim when using the motion %.

4条回答
  •  不思量自难忘°
    2020-12-03 22:48

    You could do this quite easily with a macro. You would search for the keyword with a regexp and then search for the start of the text, then the end of it, then you can undertake what ever action that you want.

    E.g. to yank the required text:

    qa/somekeyword\s*
    /(
    lvh%hyq
    

    Now whenever you use the macro with @a you would yank the next bit of text that you are interested in.

提交回复
热议问题