Vim Tips Wiki
Advertisement

This tip is too small!

This tip is too simple, too obvious, or just plain not long enough as-is. Please expand it or find a place to merge the information into another similar tip. If you don't feel up to the merge yourself feel free to add a merge suggestion in the comments section or by adding a Duplicate tag.

Tip 1666 Printable Monobook Previous Next

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 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:

type classname::methodname(args)

See also[]

Comments[]

Advertisement