Is there an easy way to jump to the beginning or end of the function your cursor is currently inside? It doesn't seem like sentence/paragraph/section have useful syntax aware meanings when editing C++.

2 Answers 2


As we cannot expect C++ code to have their function-scope brackets on the first column, we cannot rely on the default behaviour of ]] and ][.

A few weeks ago I've added this feature into lh-cpp. I won't describe here how it works as I've done it in answer to another similar question on vi.SE: Quick search, limited to a C++ function

(the idea is that I rely on ctags to parse the current file and obtain the boundaries of the current function)


I'm not aware of anything direct and foolproof. It may very well exist in a plugin somewhere, of course. ][ will take you to the next closing curly brace in column one. If your code is properly formatted, that's almost certainly the end of the function but the movement doesn't pay any attention to the syntax of any other characters at all. It just walks down column one looking for a }. ]} will take you to the end of the current code block. It does pay attention to nested braces. That may or may not be the end of the function but you can usually get there quickly by repeating it a time or two.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.