Compile and run cpp program from Vim
March 27, 2014
To compile and run cpp program from MVIM
(or VIM) directly. Add this to
your ~/.vimrc
Note: You can remove/add the <Enter>
if you prefer to press <Enter>
yourself.
Now simply hit Ctrl + c
to compile and Ctrl + x
to execute.
For a source file with name main.cpp
, commands will be expanded to
The %:r
gets the current filename without the extension whereas %
gets the current filename.
You can very easily extend above approach to compile using makefile.