Compile and Run For C/C++ programmers on vim
If the file is named file.cpp or file.c, in the vim command mode just type in:
:!make abc
:!./abc
The first command compiles file abc.cpp to the executable file abc in the current directory. You can then execute it using the second command.
Alternatively, you could use something like :!g++ -g -Wall file.cpp -o file if you want to specify your own compilation options. (Anything more complex and you should be using a Makefile anyway).
:!make abc
:!./abc
The first command compiles file abc.cpp to the executable file abc in the current directory. You can then execute it using the second command.
Alternatively, you could use something like :!g++ -g -Wall file.cpp -o file if you want to specify your own compilation options. (Anything more complex and you should be using a Makefile anyway).
In fact, the ! before make is optional. Vim just figures things out for you. Also Note: no makefile needs to be written before using this command.
ReplyDelete