Search code examples
kakoune

How to select surrounding parentheses?


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?


Solution

  • 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 [.