LoginSignup
5
4

More than 5 years have passed since last update.

Hash Rocketを1.9記法に置換するelisp

Last updated at Posted at 2013-08-17

Rubyの古いHash記法 { :foo => 'bar' } を1.9以降の記法 { foo: 'bar' } に置換するelispです。

(defun ruby-anti-hash-rocket ()
  (interactive)
  (beginning-of-line)
  (setq current-line (count-lines (point-min) (point)))
  (setq replaced (replace-regexp-in-string ":\\([a-z0-9_]+\\)\s*=>" "\\1:" (buffer-string)))
  (erase-buffer)
  (insert replaced)
  (goto-line (+ 1 current-line))
  (beginning-of-line)
  )
5
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4