Last Updated: February 25, 2016
· bunnymatic

emacs - convert hashrockets helper

As my older projects get moved into the new world order, I find the need to clean up and stop using hashrocket syntax in ruby.

Here's my emacs function to help me out.

(defun convert-hashrockets ()
  "Replace ruby hashrockets with new hash syntax"
  (goto-char 1)
  (while (search-forward-regexp ":\\([-_A-Za-z0-9]+\\)[[:space:]]=>" nil t)
    (replace-match ( concat (match-string 1) ":") t nil )))

2 Responses
Add your response


https://github.com/purcell/ruby-hash-syntax seems to be more comprehensive.

over 1 year ago ·

I hadn't see that. Good catch, and definitely more comprehensive.

over 1 year ago ·