Created
April 3, 2017 06:05
-
-
Save bstaint/a4063fc0b94b84336f2b25e4a3125a54 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
function! s:RunFunc(flag) | |
let cmdline = { 'c': 'gcc', 'cpp': 'g++' } | |
if exists('cmdline[&ft]') | |
exec 'VimProcBang '.cmdline[&ft].' %:t -Wall -g -o %:t:r.exe' | |
let output = expand('%:t:r').'.exe' | |
" 确保编译成功且生成exe | |
if a:flag == 1 && vimproc#get_last_status() == 0 | |
\ && filereadable(output) | |
echo vimproc#cmd#system(output) | |
endif | |
endif | |
endfunction | |
command! Run call <SID>RunFunc(1) | |
" 仅编译不运行 | |
command! RunOnly call <SID>RunFunc(0) | |
" 用来通过make编译py文件为pyc | |
au FileType python setlocal makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment