Reputation: 15552
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
Reputation: 881
Anyone stumbling upon this question: :Tabularize argument_list
also works.
Upvotes: 1
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