本文介绍了如何在 X 列之前插入空格以排列列中的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的复制运算符源代码,如下所示.

I have my source code for copy operators written as follows.

foo = rhs.foo;
foobar = rhs.foobar;
bar = rhs.bar;
toto = rhs.toto;

我想按如下方式排列(更易读,不是吗?).

I'd like to line things up as follows (more human readable, isn't it?).

foo    = rhs.foo;
foobar = rhs.foobar;
bar    = rhs.bar;
toto   = rhs.toto;

是否有一个 VIM 神奇的 insert-up-to-column-N,或者类似的东西,可以让我使用每行几次按键来排列东西?

Is there a VIM magic insert-up-to-column-N, or something like that that would allow me to line things up using a couple of keystrokes per line?

推荐答案

有一个很好的插件可以做到这一点以及更多,叫做 Align.vim

There is a nice plugin which does exactly that and more, called Align.vim

对于您的情况,您需要选择您的表达式,然后输入 :Align =.它将对齐所有内容,使用 = 作为分隔符和引用.

For you case, you would need to select your expression and then type :Align =. It will align everything, using = as a separator and reference.

(有很多选项可以对齐、左对齐、右对齐、循环等)

(There is a lots of options to align, left, right, cyclically, etc)

您还可以查看提供类似功能的 Tabular.vim.请参阅此处的截屏视频.

You can also check Tabular.vim which provides similar features. See the screencast there for a demo.

这篇关于如何在 X 列之前插入空格以排列列中的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 13:50