Vim - learnclang/1-helloworld GitHub Wiki
There are many fancy plugins to convert Vim into a complete C/C++ IDE, this guide aims to keep things simple and configure the minimums necessary to compile and execute the helloWorld project.

To compile and run a C program within Vim, we are going to create a Makefile to setup the project build script and rely on make to do the heavy lifting for us.
For more information on make, see here.
Create a new file named Makefile and copy the following text into it, replace gcc by the compiler of your choice.
all: run
run: hello.c
./hello
hello.c: clean
gcc ./hello.c -Wall -o ./hello
clean:
rm -f ./helloNow you can compile and execute the program by calling make from the terminal or using the :make command within Vim.
makeormake all: cleans, compiles and runs the programmake run: execute the compiled programmake hello.c: cleans and compiles the hello.c source filemake clean: cleans previous executables
In order to facilitate things, you can map the make call + open a quickfix window with the compiler output to a key (e.g. <Leader>r) adding this to your .vimrc file.
map <Leader>r :make<CR>:copen<CR><CR>