10.9 Programming Assistanceelvis ' programming assistance capabilities are described in this section. 10.9.1 Edit-Compile Speedupelvis 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 .
The If you supply additional arguments to the The Similarly, the elvis
captures the output of the
compile or make
, and looks for things that look
like filenames and line numbers. When it finds likely candidates, it
treats them as such, and moves to the location of the first error.
The If you supply a filename
argument to
The vi
mode command Finally, one really nice feature is that elvis compensates for changes in the file. As you add or delete lines, elvis keeps track, so that when you go to the next error, you end up on the correct line, which is not necessarily the one with the same absolute line number as in the compiler's error message. 10.9.2 Syntax Highlighting
To cause elvis
to do syntax highlighting, use
the
The description of each language's comments, functions, keywords, etc., is stored in the elvis.syn file. This file comes with a number of specifications in it already. As an example, here is the syntax specification for Awk: # Awk. This is actually for Thompson Automation's AWK compiler, which is # somewhat beefier than the standard AWK interpreter. language tawk awk extension .awk keyword BEGIN BEGINFILE END ENDFILE INIT break continue do else for function keyword global if in local next return while comment # function ( string " regexp / useregexp (,~ other allcaps The format is mostly self-explanatory, and is fully documented in the elvis online documentation. The reason elvis
associates fonts with different
parts of a file's syntax is its ability to print files as they're
shown on the screen (see the discussion of the In addition to specifying the font to use for each kind of item,
you can associate a color with each kind of font (normal
,
italic
, and so on).
This is done with the On a non-bitmapped display such as the Linux console, all of the fonts map into the one used by the console driver. This makes it rather difficult to distinguish normal from italic , for example. However, on some displays (such as the Linux console), you can still change the color of the different fonts. If you have a Linux system with elvis , use it to edit a convenient C source file, and then issue the following commands: :display syntax :color normal white :color bold yellow :color emphasized green :color italic cyan :color fixed red Your screen will change to highlight C keywords in yellow, comments in light blue, preprocessor directives in green, and character and string constants in red. We regret that we can't reproduce the effect here in print. :-) In elvis , the syntax colors are per-window attributes. You can change the color for the italic font in one window, and it will not affect the color for the italic font in another window. This is true even if both windows are showing the same file. Syntax coloring makes program editing much more interesting and lively. But you have to be careful in your choice of colors! |
|