How do I jump between sections using [[ and ]] motions?
Answer
]] and [[
Explanation
The ]] and [[ motions jump between sections, traditionally defined as lines starting with { in the first column. In practice, this jumps between function definitions in C-like code.
How it works
]]jumps forward to the next section start (opening{in column 1)[[jumps backward to the previous section start][jumps forward to the next section end (closing}in column 1)[]jumps backward to the previous section end
Example
void foo() {
...
}
void bar() {
...
}
With the cursor in foo, pressing ]] jumps to the { of bar.
Tips
- In languages without column-1 braces, these may not work as expected
- Some filetypes remap these to language-specific section jumps
- Counts work:
3]]jumps forward 3 sections - Can be used with operators:
d]]deletes to the next section