How do I jump to the opening or closing brace of the block surrounding my cursor?
Answer
[{ and ]}
Explanation
The [{ motion jumps to the previous unmatched { — the opening brace of the block enclosing your cursor. Its counterpart ]} jumps forward to the next unmatched }. These are distinct from %, which hops between a matched pair. [{ intentionally skips fully closed inner blocks and finds the nearest unmatched { — the one that actually contains your current position.
This makes them essential for deep code navigation: jump straight to the function or if-block header without scrolling or counting lines.
How it works
[{— scan backwards, counting{and}until an unmatched{is found]}— scan forwards, counting}and{until an unmatched}is found- Analogous commands for parentheses:
[(and]) - The
[prefix means "backwards/up";]means "forwards/down"
Example
Given this code with the cursor on the return line:
void process() {
if (ready) {
for (int i=0; i<n; i++) {
return; ← cursor here
}
}
}
[{moves the cursor to the{on theforline[{again moves to the{on theifline[{once more moves to the{on thevoid process()line
Tips
- Prefix with a count:
2[{skips to the second enclosing brace instead of the immediate one - Use
[(and])for the same behaviour with parentheses — useful inside function call arguments - Combine with operators:
d[{deletes from the cursor back to the enclosing{;v[{selects the region for further action - Works in any file with C-style braces, including JavaScript, Go, Java, and more