compile c cpp with cl.exe in vim

1 touch a clc.bat

@echo off
set f1=%1
set f2=%f1:.c=%
:: Load compilation environment
call "C:\Users\administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat"
:: Invoke compiler with any options passed to this batch file
"C:\Users\administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin\cl.exe" %f1%  
echo --------------------------------------------------------------------------------------
%f2%

2 touch a clcpp.bat

@echo off
set f1=%1
set f2=%f1:.cpp=%
:: Load compilation environment
call "C:\Users\administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat"
:: Invoke compiler with any options passed to this batch file
"C:\Users\administrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin\cl.exe" %f1%
echo -----------------------------------------------------------------------
%f2%

3 add clc.bat clcpp.bat to env

4 _vimrc

autocmd filetype c nnoremap <F5> :w! <bar> exec '!clc '.shellescape('%')<CR>
autocmd filetype cpp nnoremap <F5> :w! <bar> exec '!clcpp '.shellescape('%')<CR>
posted @ 2017-10-25 15:02  idlewith  阅读(186)  评论(0编辑  收藏  举报