"compile c c++ file in quickfix
nmap <F4> :call DoOneFileMake()<CR>
function DoOneFileMake()
if(expand("%:p:h")!=getcwd())
echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press redirect to the dir of this file."
endif
exec "w"
call SetCompilation()
exec "make"
exec '!time ./%<'
exec "copen"
endfunction
function SetCompilation()
if &filetype=='c'
set makeprg=gcc\ %\ -o\ %<
elseif &filetype=='cpp'
set makeprg=g++\ %\ -o\ %<
endif
endfunction
截取自我自己的.vimrc
具体从哪抄来的就不知道了,
效果: