Tip 105Compile Code Without Leaving Vim

Calling an external compiler from Vim saves us from having to leave our editor—and if the compiler reports any errors, Vim provides the means for us to jump between them quickly.

Preparation

We’ll use a small C program to demonstrate. The source files are distributed with this book (for more details, refer to Downloading the Examples). In the shell, change to the code/quickfix/wakeup directory:

=> $ cd code/quickfix/wakeup

You’ll need gcc to build this program, but don’t feel that you need to install a compiler just to follow this tip. The workflow here demonstrates the task for which the quickfix list was originally conceived (and from which it takes its name). As we’ll soon see, this feature ...

Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.