tags:

views:

70

answers:

2

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.

A: 

You should try the align plugin.

Tassos
That basically does the exact same thing as Tabular. Unless you had a regular expression to use with that I don't see your point.
rspeicher
I should had mention that \ts, have the same effect as the correct answer.
Tassos
Yes it does the same thing easier: \ts, edit:sorry for the double comment (browser fault).
Tassos
+1  A: 

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'/
Peter Rincker
Perfect! Thank you.
rspeicher