vim tabular 只在第一场比赛就行? [英] vim tabular only on the first match on the line?

查看:26
本文介绍了vim tabular 只在第一场比赛就行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 tabular.vim 插件格式化一些 python 代码.它目前是一个 sqlalchemy 声明类,看起来像这样:

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

只是一个普通的

: Tabularize /=

似乎匹配一切,一切都变得疯狂.

seems to match everything, and everything goes crazy.

提前非常感谢!

推荐答案

你可以使用这个命令:

:Tabularize /^[^=]*zs=

模式只匹配第一个 =.

您可以将这两行添加到 ~/.vim/after/plugin/TabularMaps.vim

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 tabular 只在第一场比赛就行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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