Vim:转到下一个方法的开头/结尾 [英] Vim: Go to Beginning/End of Next Method

查看:245
本文介绍了Vim:转到下一个方法的开头/结尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vim中是否有本机功能允许用户将光标移动到下一个方法的开头/结尾?我已经知道 [[]] [] ] [,但这些并没有削减工作,因为它们只适用于零列的大括号。因此,它们在导航C ++代码方面几乎没用。是否有这样的命令已经内置到Vim中?如果没有,你会推荐一个实现它的插件吗?

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?

感谢您的帮助!

编辑: [{}] 将不会一直有效,因为你必须在 {} (而不是在该区块内的某个更深的范围内),您最终会在右边 {} 之后。

[{ 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.

编辑2:这是一个代码清单,其中 [m 和朋友不工作。

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; }

}


推荐答案

Vim具有 [m / ] m 内置for Java或类似结构化语言。

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

我编写了自定义版本来处理 Vim函数 VBScript 批处理文件等。这些都是由我的 CountJump插件提供支持,可用于编写基于正则表达式的自定义跳转函数。

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.

这篇关于Vim:转到下一个方法的开头/结尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆