Skip to content

Instantly share code, notes, and snippets.

@ahawthorne
Last active September 28, 2015 21:26
Show Gist options
  • Save ahawthorne/a67fffb01796c04b51de to your computer and use it in GitHub Desktop.
Save ahawthorne/a67fffb01796c04b51de to your computer and use it in GitHub Desktop.
Vim command to fix ruby hashes. Make them in 1.9 format
function! s:FixHash(line1,line2)
let l:save_cursor = getpos(".")
silent! execute ':' . a:line1 . ',' . a:line2 . 's/\%(''\|:\)\([a-zA-Z0-9_]\+\)\%(\s*=>\|''\s*=>\|'':\)/\1:/g'
call setpos('.', l:save_cursor)
endfunction
command! -range=% FixHash call <SID>FixHash(<line1>,<line2>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment