How to move from one C/C++ function to the next (both directions)

I believe you are looking for ]] which jumps to the next { char on the first column.

There are similar options, just try :help ]] for more information.


Regarding the use of [[ and ]], note the following from motion.txt in the vim docs:

If your '{' or '}' are not in the first column, and you would like to use "[["
and "]]" anyway, try these mappings:
   :map [[ ?{w99[{
   :map ][ /}b99]}
   :map ]] j0[[%/{
   :map [] k$][%?}

I use these mappings which will make [[ and ]] work with functions that don't put the starting { at the beginning of the line.

map ]] :call search("^\\(\\w.*\\)\\?{")<CR>
map [[ :call search("^\\(\\w.*\\)\\?{", "b")<CR>
map ][ :call search("^}")<CR>
map [] :call search("^}", "b")<CR>

Tags:

Vim