Created
August 13, 2012 08:29
-
-
Save violetyk/3338246 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function! s:replace(...) range "{{{ | |
if a:0 < 2 | |
return | |
endif | |
let range = a:firstline . ',' . a:lastline | |
let tmp = @@ | |
silent exec range . 'yank' | |
let text = @@ | |
let @@ = tmp | |
let text = substitute(text, '\C\V' . escape(a:1, '\'), escape(a:2, '&~\'), 'g') | |
silent exec "normal! :". range . "change!\<CR>" . text . "." | |
endfunction "}}} | |
command! -nargs=+ -buffer -range Replace :<line1>,<line2>call s:replace(<f-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment