Vim Tips Wiki
Advertisement

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created October 8, 2010 · complexity basic · version 7.0

This tip shows how to easily jump to the next or previous method in a C++ program.

Jump to next/previous method

Put these lines in your vimrc and you can press Alt-Shift-J (or Alt-Shift-K) to jump to the next (or previous) method in a C++ file:

nnoremap <M-J> /^\<\w*\>\s*\<\w*\>::<CR>
nnoremap <M-K> ?^\<\w*\>\s*\<\w*\>::<CR>

Better still, if this is in file ftplugin/cpp.vim, it only activates when editing C++ files.

This only works if the format of the method is:

type classname::methodname(args)

Comments

Advertisement