Vim Tips Wiki

Jump between methods in C++

Redirected from VimTip1666

1,625pages on
this wiki
Add New Page
Talk0 Share

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 methodEdit

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 alsoEdit


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.