Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
736 views
in Technique[技术] by (71.8m points)

java - Vim: Go to Beginning/End of Next Method

Is there native functionality in Vim that allows one to move the cursor to the beginning/end of the next method? I already know about [[, ]], [], and ][, but these don't cut the job, because they only work on braces that are in column zero. Hence, they are of little use in, say, navigating C++ code. Is there such a command that is already built into Vim? If not, would you recommend a plugin that does implement it?

Thanks for your help!

Edit: [{ and }] will not work all of the time, because you have to be within the block with the {} (and not in some deeper scope within that block) for you to end up at the right { or } afterwards.

Edit 2: Here's a code listing for which [m and friends don't work.

namespace foo {

#define define_foo         
    template <class T>     
    struct foo_traits<X>   
    {                      
        using foo = X;     
    };

template <class T>
struct foo_traits;

define_bar(T*, T*, T*);

template <class T>
struct baz;

template <class T>
struct baz<T&>
{
    static T* apply(T& t) { return &t; }
};

template <class T>
inline T a(T t) { return t; }

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Vim has [m / ]m built in "for Java or similar structured language".

I have written custom versions that handle Vim functions, VBScript, and batch files, among others. These are all powered by my CountJump plugin, which can be used to write custom jump functions based on regular expressions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...