开发者

Vim: Align second set of opening quotes using Tabular

I've been using the excellent Tabular plugin in Vim to align things, but there's an alignment I want to do pretty commonly that I can't figure out the right regex for.

I want this

gem 'fakeweb'
gem 'factory_girl', '~> 1.3'
gem 'factory_girl_rails', '>= 1.0'
gem 'rspec', '>= 2.0'
gem 'rspec-rails', '>= 2.0'

to turn into this

gem 'fakeweb'
gem 'factory_girl',       '~> 1.3'
gem 'factory_girl_rails', '>= 1.0'
gem 'rspec',              '>= 2.0'
gem 'rspec-rails',        '>= 2.0'

The cheat would be to align it o开发者_StackOverflown the comma, but that's not my ideal.


By using the \zs in your regex you can set the start of the match to be the quote and not the comma.

:%Tabularize /,\s*\zs'/


Anyone stumbling upon this question: :Tabularize argument_list also works.


You should try the align plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜