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.
精彩评论