How to select surrounding parentheses?

1.2k Views Asked by At

How do I select the surrounding parentheses similar to vim-surround? I know I can do <alt-a>( or m to select the text in between, but how do I get two cursors at the end?

2

There are 2 best solutions below

0
On BEST ANSWER

vim-surround functionality was implemented by kakoune-surround plugin, but, if you prefer "vanilla experience", you can change parenthesis to, say, square brackets using select:

ms\(|\)<return><space>r]<alt-n>r[
  • m — select the closest matching parenthesis (or by <alt-a>), as you mentioned);
  • s\(|\)<return> — select ( and ) using regex;
  • <space> — clear selections (cursor will be positioned on the last match);
  • r] — change ) to ];
  • <alt-n> — select previous match (it will be ( according to our regex);
  • r[ — change ( to [.
2
On

To complement Aleksandr answer, at the beginning you can use <a-S> after <a-a>(. It will select the selection boundaries, which in this case happen to be the parens.