Wikia

Vim Tips Wiki

Changes: Jump between methods in C++

Edit

Back to page

(minor tweaks)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 21: Line 21:
 
</pre>
 
</pre>
   
Better still, if this is in file <tt>ftplugin/cpp.vim</tt>, it only activates when editing C++ files.
+
Better still, if this is in file <code>ftplugin/cpp.vim</code>, it only activates when editing C++ files.
   
 
This only works if the format of the method is:
 
This only works if the format of the method is:

Latest revision as of 06:45, July 13, 2012

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

CommentsEdit

Around Wikia's network

Random Wiki