regex to find/replace 1.8 style hashes with 1.9 style
I'm in the process of converting a lot of 1.8 style hashes into 1.9 style. This is frustratingly slow to do. Of course, not really because I have vim. If you find yourself in this situation, and have a file open with a lot of these in it of the form:
render :partial => 'foo', :locals => { :giggity => 'goo' }
You can just throw this handy regex into vim for maximum awesomeness (also, if you haven't used backreferences/capture in vim, note that I have to escape the parens):
%s/:\([a-zA-Z]*\) =>/\1:/g
That'll leave you with what you want:
render partial: 'foo', locals: { giggity: 'goo' }
Anyway, I am hopeful that Nick will rebound this post with one about doing the same thing project-wide using sed. Or someone else will generate a less-specific version, that handles string keys as well at least :)
Recent Posts
- Linkdump of Awesome Stuff #24
- The Bitcraze Crazyflie is the best quadcopter ever
- Update v1.0.1: Quickly get a fresh ubuntu install ready for ruby dev
- Build your own web framework with Rack and Ruby - Part 1
- Linkdump of Awesome Stuff #23
- Quickly get a fresh ubuntu install ready for ruby dev
- It's a bird! It's a plane? No! It's Meteor coming to destroy your old ways.
- Linkdump of Awesome Stuff #22
- Fix your Python 2.7.4 MAXREPEAT ImportError issues
- Make a snappable cart directive with AngularJS