Robert Speicher
Robert Speicher

Reputation: 15552

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 on the comma, but that's not my ideal.

Upvotes: 1

Views: 606

Answers (3)

Leon
Leon

Reputation: 881

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

Upvotes: 1

Peter Rincker
Peter Rincker

Reputation: 45107

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'/

Upvotes: 2

Tassos
Tassos

Reputation: 3288

You should try the align plugin.

Upvotes: 0

Related Questions