vim表格只在第一个匹配就行了? [英] vim tabular only on the first match on the line?
本文介绍了vim表格只在第一个匹配就行了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ $ $ $ $ $ c $ id $ db.Column(db.Integer,primary_key = True )
status = db.Column(db.Integer,nullable = False,default = 3)
... etc ...
我想只能对齐列表中的第一个等号。
id = db.Column(db.Integer,primary_key = True)
status = db.Column(db。 Integer,nullable = False,default = 3)
... etc ...
只是一个普通的
:Tabularize / =
似乎可以配合一切,一切都变得疯狂。
非常感谢! 命令:
:Tabularize / ^ [^ =] * \zs =
该模式只与第一个 =
匹配。
您可以将这两行添加到〜/ .vim / after / plugin / TabularMaps.vim
AddTabularPattern 1 = / ^ [^ =] * \ zs =
AddTabularPattern 1 == / ^ [^ =] * \zs = / r0c0l0
下一次运行:
:Tabularize 1 =
如果您不需要 =
周围的空格,请运行:
:Tabularize 1 ==
I'm trying to format some python code with the tabular.vim plugin. It's currently a sqlalchemy declarative class, and looks something like this:
id = db.Column(db.Integer, primary_key=True)
status = db.Column(db.Integer, nullable=False, default=3)
...etc...
I'd like to be able to align only the very first equals sign in the list.
id = db.Column(db.Integer, primary_key=True)
status = db.Column(db.Integer, nullable=False, default=3)
...etc...
Just a regular
: Tabularize /=
seems to match everything, and everything goes crazy.
Thanks very much in advance!
解决方案
You can use this command:
:Tabularize /^[^=]*\zs=
The pattern only matches the first =
.
You can add these two line to ~/.vim/after/plugin/TabularMaps.vim
AddTabularPattern 1= /^[^=]*\zs=
AddTabularPattern 1== /^[^=]*\zs=/r0c0l0
Next time, simply run:
:Tabularize 1=
If you don't need spaces around =
, run this:
:Tabularize 1==
这篇关于vim表格只在第一个匹配就行了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文