-
-
Save thenoseman/3717195 to your computer and use it in GitHub Desktop.
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
fun! EvalVimScriptRegion(s,e) | |
let lines = getline(a:s,a:e) | |
let file = tempname() | |
cal writefile(lines,file) | |
redir @e | |
silent exec ':source '.file | |
cal delete(file) | |
redraw | |
redir END | |
echo "Region evaluated." | |
if strlen(getreg('e')) > 0 | |
10new | |
redraw | |
silent file "EvalResult" | |
setlocal noswapfile buftype=nofile bufhidden=wipe | |
setlocal nobuflisted nowrap cursorline nonumber fdc=0 | |
" syntax init | |
set filetype="eval" | |
syn match ErrorLine +^E\d\+:.*$+ | |
hi link ErrorLine Error | |
silent $put =@e | |
endif | |
endf | |
augroup VimEval | |
au! | |
au filetype vim :command! -range Eval :cal EvalVimScriptRegion(<line1>,<line2>) | |
au filetype vim :vnoremap <silent> e :Eval<CR> | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment