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.
Written by Dan Croak
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#