How do I jump to the matching bracket or parenthesis?
Answer
%
Explanation
The % command jumps to the matching bracket, parenthesis, or brace. Place your cursor on any (, ), [, ], {, or } character and press % to jump to its matching pair.
How it works
Vim finds the matching delimiter and moves the cursor to it. If pressed again, it jumps back to the original one. This works with:
()parentheses[]square brackets{}curly braces
Example
function hello(name) {
console.log(name)
}
With the cursor on the { on line 1, pressing % jumps to the } on line 3.
Tips
- You can use
%with operators:d%deletes from the cursor to the matching bracket v%visually selects everything between matching delimiters- If the cursor is not on a bracket, Vim searches forward on the current line to find one