Skip to content

Instantly share code, notes, and snippets.

@brendanjerwin
Created May 8, 2012 13:22
Show Gist options
  • Select an option

  • Save brendanjerwin/2634935 to your computer and use it in GitHub Desktop.

Select an option

Save brendanjerwin/2634935 to your computer and use it in GitHub Desktop.
function! Refactor()
call inputsave()
let @z=input("What do you want to rename '" . @z . "' to? ")
call inputrestore()
endfunction
" Locally (local to block) rename a variable
autocmd FileType coffee nmap <buffer> <Leader>rr "zyiw:call Refactor()<cr>mx:silent! norm gd<cr>Vii%:s/<C-R>//<c-r>z/g<cr>`x
autocmd FileType javascript nmap <buffer> <Leader>rr "zyiw:call Refactor()<cr>mx:silent! norm gd<cr>[{V%:s/<C-R>//<c-r>z/g<cr>`x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment