I\'ve been using the following script in my vimrc file for compiling and running C programs;
autocmd filetype c nnoremap :w exec \'!gcc \'.sh