Created
April 3, 2013 13:54
-
-
Save pfmoore/5301385 to your computer and use it in GitHub Desktop.
Vim script/function to pipe selection through a command (or run it as Vim script)
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
function! ExecRange(cmd) range | |
let l:old_a = @a | |
exec a:firstline . ',' . a:lastline . 'yank a' | |
if a:cmd == '' | |
exec @a | |
else | |
echo system(a:cmd, @a) | |
endif | |
let @a = l:old_a | |
endfunction | |
command! -nargs=* -range=% ExecRange <line1>,<line2>call ExecRange(<q-args>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment