This tip shows how to easily jump to the next or previous method in a C++ program using a simple regular expression.
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> /\v^(\w+\s+)?\w+::\w+\(.*\) nnoremap <M-K> ?\v^(\w+\s+)?\w+::\w+\(.*\)
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:
- Highlighting of method names in the definition for a syntax-file addition to emphasize method names