let s:rs_inc
=
"
d:/share/projects/c/include
"
let s:mingw_home = " c:/mingw/ "
let s:bc_home = " c:/progra~1/borland/bcc/ "
let s:msc_home = " c:/progra~1/micros~4/vc98/ "
let s:msc_common = " c:/progra~1/micros~4/common/msdev98/bin "
let s:cpp_objext = " .obj "
let s:cpp_binext = " .exe "
let s:cpp_dbgext = " .pdb "
" if executable( " tee " )
" set shellpipe=2>&1| tee
" endif
function CppSetEnvDefault()
let s:cpp_mkp = " g++ "
let s:cpp_cop = " -c -o "
let s:cpp_bop = " -o "
let s:cpp_args = " -Wall -g "
let s:cpp_largs = ""
endfunction
function CppSetEnvMingw()
if isdirectory(s:mingw_home)
let cpp_home = s:mingw_home
let cpp_bin = cpp_home. " bin/ "
let $PATH . = " ; " .cpp_bin
let Inc = cpp_home. " include/ "
let Lib = cpp_home. " lib/ "
let Opt = " -Wall -g "
let Iop = " -I "
let Lop = " -L "
let s:cpp_cop = " -c "
let s:cpp_cfo = " -o "
let s:cpp_bfo = " -o "
let s:cpp_compr = " gcc "
let s:cpp_mkp = " g++ "
let s:cpp_args = Opt.Iop.Inc.Iop.s:rs_inc
let s:cpp_largs = Lop.Lib
endif
endfunction
function CppSetEnvBc()
if isdirectory(s:bc_home)
let cpp_home = s:bc_home
let cpp_bin = cpp_home. " bin/ "
let $PATH . = " ; " .cpp_bin
let Inc = cpp_home. " include/ "
let Lib = cpp_home. " lib/ "
let Opt = " -w-8027 -w-8057 -w-8060 -v "
let Iop = " -I "
let Lop = " -L "
let s:cpp_cop = " -c "
let s:cpp_cfo = " -o "
let s:cpp_bfo = " -e "
let s:cpp_compr = " bcc "
let s:cpp_mkp = " bcc32 "
let s:cpp_args = Opt.Iop.Inc.Iop.s:rs_inc
let s:cpp_largs = Lop.Lib
endif
endfunction
function CppSetEnvMsc()
if isdirectory(s:msc_home)
let cpp_home = s:msc_home
let cpp_bin = cpp_home. " bin/ "
let $PATH . = " ; " .cpp_bin. " ; " .s:msc_common
let Inc = cpp_home. " include/ "
let Lib = cpp_home. " lib/ "
let Opt = " /nologo /ZI /GX /FD "
let Iop = " /I "
let Lop = " /link /libpath: "
let s:cpp_cop = " /c "
let s:cpp_cfo = " /Fo "
let s:cpp_bfo = " /Fe "
let s:cpp_dfo = " /Fd "
let s:cpp_dop = " /debug /pdbtype:con "
let s:cpp_compr = " msvc "
let s:cpp_mkp = " cl "
let s:cpp_args = Opt.Iop.Inc.Iop.s:rs_inc
let s:cpp_largs = Lop.Lib
endif
endfunction
function CppCompile()
exe " compiler " .s:cpp_compr
exe " set mp= " .s:cpp_mkp
let CppCompCmd = s:cpp_args.s:cpp_cop
if exists( " s:cpp_cfo " )
let CppCompCmd . = s:cpp_cfo. " " " .expand( " %:p:r " ).s:cpp_objext. " " "
endif
if exists( " s:cpp_dfo " )
let CppCompCmd . = s:cpp_dfo. " " " .expand( " %:p:r " ).s:cpp_dbgext. " " "
endif
let CppCompCmd . = " " " .expand( " %:p " ). " " "
exe " make " .CppCompCmd
exe " :botright cwindow "
exe " set mp=make "
endfunction
function CppBuild()
exe " compiler " .s:cpp_compr
exe " set mp= " .s:cpp_mkp
let CppBuildCmd = s:cpp_args
let CppBuildArgs = s:cpp_largs
" only msvc has independent debug file
if exists( " s:cpp_dfo " )
let CppBuildCmd . = s:cpp_dfo. " " " .expand( " %:p:r " ).s:cpp_dbgext. " " "
if exists( " s:cpp_cfo " )
let CppBuildCmd . = s:cpp_cfo. " " " .expand( " %:p:r " ).s:cpp_objext. " " "
endif
let CppBuildArgs . = s:cpp_dop
endif
if exists( " s:cpp_bfo " )
let CppBuildCmd . = s:cpp_bfo. " " " .expand( " %:p:r " ).s:cpp_binext. " " "
endif
let CppBuildCmd . = " " " .expand( " %:p " ). " " "
let CppBuildCmd . = CppBuildArgs
exe " make " .CppBuildCmd
exe " :botright cwindow "
exe " set mp=make "
endfunction
function CppRun()
let CppRunCmd = expand( " %:p:r " ). " .exe "
exe " ! " .CppRunCmd
endfunction
exe " amenu <silent> " . ' &Tools.-SEP5- : '
exe " amenu <silent> " . ' &Tools.&Compile <C-C>:call CppCompile()<CR>:redraw<CR> '
exe " amenu <silent> " . ' &Tools.&Build <C-C>:call CppBuild()<CR>:redraw<CR> '
exe " amenu <silent> " . ' &Tools.&Run <C-C>:call CppRun()<CR> '
set guifont = Lucida_Console:h8:cANSI
set nobk ai si ci sw = 4 ts = 4 nu sm vb t_vb =
if has( " cscope " )
set csto = 0
set cst
set nocsverb
" add any database in current directory
if filereadable( " cscope.out " )
silent cs add cscope. out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
silent cs add $CSCOPE_DB
endif
set csverb
endif
if has( " autocmd " )
au GUIEnter * simalt ~ x
endif
let s:mingw_home = " c:/mingw/ "
let s:bc_home = " c:/progra~1/borland/bcc/ "
let s:msc_home = " c:/progra~1/micros~4/vc98/ "
let s:msc_common = " c:/progra~1/micros~4/common/msdev98/bin "
let s:cpp_objext = " .obj "
let s:cpp_binext = " .exe "
let s:cpp_dbgext = " .pdb "
" if executable( " tee " )
" set shellpipe=2>&1| tee
" endif
function CppSetEnvDefault()
let s:cpp_mkp = " g++ "
let s:cpp_cop = " -c -o "
let s:cpp_bop = " -o "
let s:cpp_args = " -Wall -g "
let s:cpp_largs = ""
endfunction
function CppSetEnvMingw()
if isdirectory(s:mingw_home)
let cpp_home = s:mingw_home
let cpp_bin = cpp_home. " bin/ "
let $PATH . = " ; " .cpp_bin
let Inc = cpp_home. " include/ "
let Lib = cpp_home. " lib/ "
let Opt = " -Wall -g "
let Iop = " -I "
let Lop = " -L "
let s:cpp_cop = " -c "
let s:cpp_cfo = " -o "
let s:cpp_bfo = " -o "
let s:cpp_compr = " gcc "
let s:cpp_mkp = " g++ "
let s:cpp_args = Opt.Iop.Inc.Iop.s:rs_inc
let s:cpp_largs = Lop.Lib
endif
endfunction
function CppSetEnvBc()
if isdirectory(s:bc_home)
let cpp_home = s:bc_home
let cpp_bin = cpp_home. " bin/ "
let $PATH . = " ; " .cpp_bin
let Inc = cpp_home. " include/ "
let Lib = cpp_home. " lib/ "
let Opt = " -w-8027 -w-8057 -w-8060 -v "
let Iop = " -I "
let Lop = " -L "
let s:cpp_cop = " -c "
let s:cpp_cfo = " -o "
let s:cpp_bfo = " -e "
let s:cpp_compr = " bcc "
let s:cpp_mkp = " bcc32 "
let s:cpp_args = Opt.Iop.Inc.Iop.s:rs_inc
let s:cpp_largs = Lop.Lib
endif
endfunction
function CppSetEnvMsc()
if isdirectory(s:msc_home)
let cpp_home = s:msc_home
let cpp_bin = cpp_home. " bin/ "
let $PATH . = " ; " .cpp_bin. " ; " .s:msc_common
let Inc = cpp_home. " include/ "
let Lib = cpp_home. " lib/ "
let Opt = " /nologo /ZI /GX /FD "
let Iop = " /I "
let Lop = " /link /libpath: "
let s:cpp_cop = " /c "
let s:cpp_cfo = " /Fo "
let s:cpp_bfo = " /Fe "
let s:cpp_dfo = " /Fd "
let s:cpp_dop = " /debug /pdbtype:con "
let s:cpp_compr = " msvc "
let s:cpp_mkp = " cl "
let s:cpp_args = Opt.Iop.Inc.Iop.s:rs_inc
let s:cpp_largs = Lop.Lib
endif
endfunction
function CppCompile()
exe " compiler " .s:cpp_compr
exe " set mp= " .s:cpp_mkp
let CppCompCmd = s:cpp_args.s:cpp_cop
if exists( " s:cpp_cfo " )
let CppCompCmd . = s:cpp_cfo. " " " .expand( " %:p:r " ).s:cpp_objext. " " "
endif
if exists( " s:cpp_dfo " )
let CppCompCmd . = s:cpp_dfo. " " " .expand( " %:p:r " ).s:cpp_dbgext. " " "
endif
let CppCompCmd . = " " " .expand( " %:p " ). " " "
exe " make " .CppCompCmd
exe " :botright cwindow "
exe " set mp=make "
endfunction
function CppBuild()
exe " compiler " .s:cpp_compr
exe " set mp= " .s:cpp_mkp
let CppBuildCmd = s:cpp_args
let CppBuildArgs = s:cpp_largs
" only msvc has independent debug file
if exists( " s:cpp_dfo " )
let CppBuildCmd . = s:cpp_dfo. " " " .expand( " %:p:r " ).s:cpp_dbgext. " " "
if exists( " s:cpp_cfo " )
let CppBuildCmd . = s:cpp_cfo. " " " .expand( " %:p:r " ).s:cpp_objext. " " "
endif
let CppBuildArgs . = s:cpp_dop
endif
if exists( " s:cpp_bfo " )
let CppBuildCmd . = s:cpp_bfo. " " " .expand( " %:p:r " ).s:cpp_binext. " " "
endif
let CppBuildCmd . = " " " .expand( " %:p " ). " " "
let CppBuildCmd . = CppBuildArgs
exe " make " .CppBuildCmd
exe " :botright cwindow "
exe " set mp=make "
endfunction
function CppRun()
let CppRunCmd = expand( " %:p:r " ). " .exe "
exe " ! " .CppRunCmd
endfunction
exe " amenu <silent> " . ' &Tools.-SEP5- : '
exe " amenu <silent> " . ' &Tools.&Compile <C-C>:call CppCompile()<CR>:redraw<CR> '
exe " amenu <silent> " . ' &Tools.&Build <C-C>:call CppBuild()<CR>:redraw<CR> '
exe " amenu <silent> " . ' &Tools.&Run <C-C>:call CppRun()<CR> '
set guifont = Lucida_Console:h8:cANSI
set nobk ai si ci sw = 4 ts = 4 nu sm vb t_vb =
if has( " cscope " )
set csto = 0
set cst
set nocsverb
" add any database in current directory
if filereadable( " cscope.out " )
silent cs add cscope. out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
silent cs add $CSCOPE_DB
endif
set csverb
endif
if has( " autocmd " )
au GUIEnter * simalt ~ x
endif
从我的_vimrc中拷出来的,参考了www.vim.org 排名靠前的c.vim插件。调用CppSetEnvXX设置当前编译环境,然后调用CppCompile进行编译,CppBuild编译+链接