16
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruby 1.8のハッシュロケットを使ってしまって斧を投げられないように、一発で1.9形式に変換するvimの設定

Posted at

現実逃避のための小ネタ。
Inspired by Ruby - Hash Rocketを1.9記法に置換するelisp - Qiita [キータ]

elispがあるんだからvimも書いておこう。

" to 1.9 hash
vnoremap <silent> <C-h> :s/:\([a-zA-Z0-9_]\+\)\s*=>/\1:/g<CR>

Shift-Vとかで複数行選択してやれば、特定範囲でサクっと。
自分は手頃なキーマップが空いてなかったのでビジュアルモードにだけ割り当ててるけど、その他でも使いたかったらvnoremapをnnoremapに変えれば、ノーマルモードでもそのまま利用できる。
その時はカーソルのある行だけ。

逆方向の変換? 不要ですよね。

16
17
0

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
16
17

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?