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

I just want to move from one function to the next in .c / .cpp files. How to do it?

+5
source share
4 answers

I believe that you are looking for ]]one that goes to the next {char in the first column.

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

+9
source

Regarding the use of [[and]], note the following from the motion.txt file in 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$][%?}
+7

I use these mappings that will work [[and]] with functions that don't put the beginning {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>
+2
source

Take a look at exuberant-ctags, it works with Emacs, and your “vim” thing; -)

+1
source

All Articles