6xeioa
Last Updated: February 25, 2016
·
1.367K
· croaky
8e2b996de3842c6ef7e68a82fa5f01f5

Vim Mappings for a Ruby Style Guide

Convert Ruby 1.8 to 1.9 hash syntax:

nnoremap <Leader>: :%s/:\([^ ]*\)\(\s*\)=>/\1:/gc<CR>

Add whitespace inside of braces {}:

nnoremap <Leader>{ :%s/{\([^ ]\)/{ \1/gc<CR>
nnoremap <Leader>} :%s/\([^ ]\)}/\1 }/gc<CR>

As these are not commonly used, it may be more appropriate to add them into a
separate file such as ~/.vimrc.refactoring. Then, source that file when
needed in the current Vim session:

source ~/.vimrc.refactoring

Bonus: how to convert to Ruby 1.9 hash syntax for a whole project.

Say Thanks
Respond