How to jump to the beginning of the current function body in Vim?

[m

Go to [count] previous start of a method

Works for Java or similar structured languages, and for Python as well.


C language [[

If your C code is in the non-Egyptian style:

[[

[m only works if you have an enclosing {} around the function, e.g. class { method(){} } for Java / C++.

And this is a good bet that works for both Egyptian and non-Egyptian braces:

?^[^ \t#]

Examples:

void egypt() {
#define DONTCARE 1
    int indented code = 1;
}

void tpyge()
{
#define DONTCARE 1
    int indented code = 1
} 

For functions contained in a pair of curly-braces {}:

Jump to beginning: [{

Jump to end: ]}

Replace the curly-blackets by parens or square-brackets for functions that use those.

Tags:

Vim