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).

Comments

  1. 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

Post a Comment

Popular posts from this blog

Coke Studio: Madari English Meaning and Lyrics

AJAX और हिंदी

Sadi Gali - Punjabi Lyrics and Meaning (in English) - Tanu Weds Manu

Tune Meri Jaana Kabhi Nahin Jaana - Lonely (Emptiness) - IIT Guwahati - Rohan Rathore

public static is harmful. It has no home in modern programming.