top of page

"Can you grab or delete between parentheses in vi/vim?"




This post extends a good stackoverflow [answer] answer to "Can you grab or delete between parentheses in vi/vim?" from by [hop] (asked by [romandas]).


You'd like to transform :

...into:

...and your cursor is here:

Type v2i)c to select everything between the outer parenthesis, but not the parenthesis, c to change it then type argc != 2, a.k.a. v enters visual mode, specify you want to go 2 levels of parenthesis up then i) to select everything between the block and c deletes everything selected and puts you into INSERT mode.


Use a) instead of i) to select everything in the block and the parenthesis.


Type :help object-select for help with this and related commands. Type :q to exit help.



References

  • Original stackoverflow post [link]

  • Vim image from [link]

bottom of page