function! My_compile_command() let l:ext = expand("%:e") if (l:ext == "cpp") exec "!g++ ".expand("%") elseif (l:ext == "c") exec "!gcc ".expand("%") endif endfunction nmap <silent> <leader>gg :call My_compile_command()<cr> nmap <silent> <leader>ea :!./a.out<cr>