找到一个小工具tinycc,可以直接运行c的源代码
为了方便,可以先写个批处理
tcs.bat
======================
@c:/tcc/tcc -lgdi32 -lkernel32 -lmsvcrt -luser32 -run %1
======================
在VIM中如果想快速测试一小片代码,就可以直接运行
:! tcs %
在把快捷键ctrl+f5绑定上去
map <silent> <C-F5> :!tcs %<CR><CR>
如果就C++版本就更好了
=====================================
PS:c++其实也可以,不过就是有点慢了
gcs.bat
=======================
@g++ %1 -o %1.exe
@if %errorlevel% neq 0 goto error
@%1.exe
@del %1.exe
@sleep 0.1
@exit 0
:error
@echo compile error
=======================
if (g:isWin)
map <silent> <C-F5> :! gcs.bat % <CR><CR>
else
map <silent> <C-F5> :! g++ % -o %.exe && %.exe && rm %.exe <CR><CR>
endif