How do I jump to the next or previous method start using built-in motions?
Answer
]m / [m
Explanation
When you're reviewing or refactoring C-style code, jumping by words or paragraphs is too coarse, and search can become noisy. Vim's bracket motions ]m and [m move directly between method/function starts by scanning for unmatched { boundaries. This gives you a fast structural navigation layer without plugins or LSP dependencies.
How it works
]mjumps to the start of the next method (next unmatched{in method-like structure)[mjumps to the start of the previous method- These motions are syntax-aware enough for common C-style languages where function bodies are delimited by braces
- They are ideal for quick code audits, stepping through handlers, or reviewing adjacent functions in large files
Example
Given:
func alpha() {
// ...
}
func beta() {
// ...
}
func gamma() {
// ...
}
With the cursor inside alpha, press ]m to jump to beta, then ]m again to gamma. Use [m to move back up the function list.
Tips
- Pair with
%to jump between a function's opening and closing brace once you land on it - Use this when search results are too broad (for example many repeated identifiers)
- In deeply nested blocks, this motion is often more stable than ad-hoc
/^funcsearches