Last active
December 12, 2015 08:38
-
-
Save summivox/4745235 to your computer and use it in GitHub Desktop.
VIM mapping for quick replacing of keyword under cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" quick refactoring: replace keyword under cursor | |
" `<leader>s`: main mapping | |
" `<SID>R`: arbitrary local mapping | |
" stores original position into `s before action | |
function! My_refactor(prefix) | |
return ':' . a:prefix . '%s/\<' . @" . '\>//g' | |
endfunction | |
nnoremap <special> <expr> <SID>refactor My_refactor('') | |
nmap <special> <leader>s msyiw<SID>refactor<left><left> | |
" delete trailing space in all lines | |
nnoremap <silent> <leader>dt :%s/\s\+$/<CR>:noh<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment