How to compile your code from within the program?
Do following set of commands to compile C code.
:set makeprg=gcc\ -g\ %
This command needs to be set only once.
Then repeat following command whenever you need to compile the source code.
:make
From the above command gcc can be replaced with different compiler commands for perl, python, verilog rtl etc.