How do I run a C program from VIM?

:!gcc -o somename % && ./somename
When using :!, % will be substituted by the name of the currently opened file.

When your project becomes larger, you can also write a makefile and compile the current project with :make, if there are any errors, vim will jump to them automatically.

Leave a Comment