Reputation: 44678
I just want to jump to from one function to the next in .c/.cpp files. How do I do that?
Upvotes: 8
Views: 3098
Reputation: 39
If you use taglist, I added a feature that does just that. You can jump from one tag to the other using Ctrl-up & Ctrl-down, provided the language is supported by taglist.
Here: https://github.com/man9ourah/taglist
and this to your .vimrc
.
nmap <silent> <c-up> <plug>(TlistJumpTagUp) " Map ctrl-up to move one tag up
nmap <silent> <c-down> <plug>(TlistJumpTagDown) " Map ctrl-down to move one tag down
Upvotes: 0
Reputation: 366
Simply use ]m
to jump to the next method, [m
to jump to the previous method.
In your ~/.vimrc
, you can do
nnoremap ]m ]mzz
nnoremap [m [mzz
so that everytime you jump between methods, you put the method at the center of your screen.
Upvotes: 6
Reputation: 2236
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>
Upvotes: 3
Reputation: 212674
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$][%?}
Upvotes: 7
Reputation: 8447
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.
Upvotes: 10
Reputation: 3906
Take a look at exuberant-ctags it works with Emacs, and your "vim" thing ;-)
Upvotes: 1