Skip to content

Instantly share code, notes, and snippets.

@calebhearth
Last active December 11, 2015 11:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calebhearth/4597881 to your computer and use it in GitHub Desktop.
Save calebhearth/4597881 to your computer and use it in GitHub Desktop.

Useful Vim mappings

...you didn't know you wanted

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, say ~/.vimrc.refactoring, and that file when needed to the current vim session:

source ~/.vimrc.refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment