本文介绍了Vim:源代码格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看枚举:

enum TestEnum
{
    First = 1,
    Second = 2,
    Unknown = 3,
    TestTestTest = 100,
    Zero = 0,
    Foo = 123,
}

如何使用Vim的全部功能重新格式化它?

How can I use the whole power of Vim to reformat it?

enum TestEnum
{
    First           = 1,
    Second          = 2,
    Unknown         = 3,
    TestTestTest    = 100,
    Zero            = 0,
    Foo             = 123,
}

,我一行一行的移动。它和我在任何常规编辑器中一样。

Personally, I'm moving line by line and tabbing. It is the same as I would do that in any regular editor. How to do that the right way?

类成员也是如此:

class Foo
{
    SuperFoo foo1;
    RegularFoo foo2;
    SuperiorFoo foo3;
    YetAnotherFoo foo4;
    Bar bar;
}

class Foo
{
    SuperFoo        foo1;
    RegularFoo      foo2;
    SuperiorFoo     foo3;
    YetAnotherFoo   foo4;
    Bar             bar;
}

感谢

推荐答案

您可以从两个可以执行此操作的插件中收获:

You can harvest from two plug-ins that can do this stuff:





  • Align.vim, or
  • Tabular.vim

这篇关于Vim:源代码格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 10:54