Hi,
I have these 2 in place (~/.vimrc):
Code:
" -----------------------------------------------------------------------------
" f5 -> Compile (gcc) written code
map <F5> : call CompileGcc()<CR>
func! CompileGcc()
exec "w"
exec "!gcc % -o %<"
endfunc
" -----------------------------------------------------------------------------
" shift f5 ->Compile (gcc) and run written code
map <S-F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc % -o %<"
exec "! ./%<"
endfunc
F5 -> Write file + compile using gcc.
Shift-F5 -> Write file + compile file (gcc) + run file.
Tailor the above to your liking.
Hope this helps.