1
0
mirror of https://github.com/amix/vimrc synced 2025-07-04 06:44:59 +08:00

Added feature to execute code directly from vim

included support for: C, C++, Java, Python, Bash, Go and HTML
This commit is contained in:
PratyayPande
2020-07-31 17:00:07 +05:30
parent 92dab794c6
commit 66a6ff5c98
4 changed files with 38 additions and 2 deletions

27
vimrcs/run_code.vim Normal file
View File

@ -0,0 +1,27 @@
map <F5> :call CompileRun()<CR>
imap <F5> <Esc>:call CompileRun()<CR>
func! CompileRun()
exec "w"
if &filetype == 'c'
exec "!gcc % -o %<"
exec "!time ./%<"
elseif &filetype == 'cpp'
exec "!g++ % -o %<"
exec "!time ./%<"
elseif &filetype == 'java'
exec "!javac %"
exec "!time java -cp %:p:h %t:r"
elseif &filetype == 'sh'
exec "!time bash %"
elseif &filetype == 'python'
exec "!time python %"
elseif &filetype == 'html'
exec "!google-chrome % &"
elseif &filetype == 'go'
exec "!go build %<"
exec "!time go run %"
elseif &filetype == 'matlab'
exec "!time octave %"
endif
endfunc