Friday, June 22, 2018

Shortcut to jump to the start of the current method in C++

I'm looking for ways to quickly navigate and/or get contextual
information about the structure of a large C++ codebase I'm editing in
Vim.

I discovered `[m` which is supposed to go the the start of the method
in which the cursor currently resides. Instead, if the class
containing the method is itself inside a block (such as a C++
namespace, as is very often the case), the cursor will go to to the
start of the **class** instead of the start of the **method**.

For example, in the following code snippet

namespace Foo {
class Bar {
void qux()
{
// press [m with the cursor here -> *
}
}
}

Pressing [m at the asterisk will go to the start of class Bar instead
of method qux.

Is there a trivial way to fix `[m` to work as advertised? If not, is
there an alternative, perhaps as a plugin?

Thanks, D.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: