仅在VIM第一隔板对齐文本 [英] Align text only on first separator in VIM
本文介绍了仅在VIM第一隔板对齐文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有这个code:
Suppose I have this code:
width: 215px;
height: 22px;
margin-top: 3px;
background-color: white;
border: 1px solid #999999;
我要对齐这样说:
I want to align it this way:
width: 215px;
height: 22px;
margin-top: 3px;
background-color: white;
border: 1px solid #999999;
使用Align.vim我可以做:对齐\ S
使用空格作为分隔符,但有2个问题。
using Align.vim I can do :Align \s
to use whitespace as separator, but that has 2 problems
- 初始缩进一倍
- 所有空格被视为分隔符,所以最后一行搞砸
- the initial indent is doubled
- all whitespaces are considered separators, so the last line is messed up
我已经经历了很多选择Align.vim提供阅读,但我还没有找到一个方法来做到这一点。
I've read through the many options Align.vim offers, but I haven't found a way to do this.
推荐答案
如果您使用表格,那么你可以做:Tabularize /:\ ZS /
If you use Tabular, then you can just do :Tabularize /:\zs/
.
如果看一下vim.org对齐的描述,类似的调用应该为它工作。你可以尝试:对齐:\ ZS
。我不使用对齐,所以我并不积极。
Looking at Align's description on vim.org, a similar invocation should work for it. You could try :Align :\zs
. I don't use Align, so I'm not positive.
这篇关于仅在VIM第一隔板对齐文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文