Reputation: 453
Is there any way for me to define a command (i.e :compile) to compile C/C++ code inside vim? I know I can use :!g++ %:p for that but is really tricky to type all these special characters.
Thanks in advance.
Upvotes: 1
Views: 154
Reputation: 707
You can use the :make
command in Vim. By default it runs make
but you can set the makeprg
variable to be whatever program you want.
So for your example.
:set makeprg=g++\ %
and then you can
:make
Upvotes: 3
Reputation: 198324
You can use :make
(or abbreviation :mak
) to invoke your Makefile
. You can even specify a target (e.g. :mak build
). And you can always make a mapping to make it (hehe) easier to invoke.
:help :make
Upvotes: 2