10.9. Programming Assistance

elvis' programming assistance capabilities are described in this section.

10.9.1. Edit-Compile Speedup

elvis provides commands that make it easier to stay within the editor while working on a program. You can recompile a single file, rebuild your entire program, and work through compiler errors one at a time. The elvis commands are summarized in Table 10.10.

Table 10.10. elvis Program Development Commands
CommandOptionFunction
cc[!] [args]ccprgRun the C compiler. Useful for recompiling an individual file.
mak[e][!] [args]makeprgRecompile everything that needs recompiling (usually via make(1)).
er[rlist][!] [file] Move to the next error's location.

The cc command recompiles an individual source file. You run it from the colon command line. For example, if you are editing the file hello.c, and you type :cc, elvis will compile hello.c for you.

If you supply additional arguments to the :cc command, those arguments will be passed on to the C compiler. In this case, you need to supply all the arguments, including the filename.

The :cc command works by executing the text of the ccprg option. The default value is "cc ($1?$1:$2)". elvis sets $2 to the name of the current source file, and $1 to the arguments you give to the :cc command. The value of ccprg thus uses your arguments if they are present; otherwise, it just passes the current file's name to the system cc command. (You can, of course, change ccprg to suit your taste.)

Similarly, the :make ...

Get Learning the vi Editor, Sixth 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.