home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

12.9 Programming Assistance

vile 's programming assistance capabilities are discussed in this section.

12.9.1 Edit-Compile Speedup

vile uses two straightforward vi mode commands to manage program development, shown in Table 12.6 .

Table 12.6: vile Program Development vi Mode Commands
Command Function
^X ! command [RETURN]

Run command , saving the output in a buffer named [Output] .

^X ^X

Find the next error. vile parses the output and moves to the location of each successive error.

vile understands the Entering directory XXX and Leaving directory XXX messages that GNU make generates, allowing it to find the correct file, even if it's in a different directory.

The error messages are parsed using regular expressions in the buffer [Error Expressions] . vile automatically creates this buffer, and then it uses the buffer when you use ^X ^X . You can add expressions to it as needed, and it has an extended syntax that allows you to specify where filenames, line numbers, columns and so on appear in the error messages. Full details are provided in the online help, but you probably won't need to make any changes, as it works pretty well "out of the box."

vile 's error finder also compensates for changes in the file, keeping track of additions and deletions as you progress to each error.

The error finder applies to the most recent buffer created by reading from a shell command. For example, ^X!command produces a buffer named [Output] , and :e !command produces a buffer named [!command] . The error finder will be set appropriately.

You can point the error finder at an arbitrary buffer (not just the output of shell commands) using the :error-buffer command. This lets you use the error finder on the output of previous compiler or egrep runs.

12.9.2 Syntax Highlighting

vile relies on help from an external program to provide syntax coloring. In fact, there are three programs: one for C programs, one for Pascal programs, and one for UNIX man pages. The vile documentation provides this sample macro for use in a .vilerc file:

30 store-macro
	write-message "[Attaching C/C++ attributes...]"
	set-variable %savcol $curcol
	set-variable %savline $curline
	set-variable %modified $modified
	filter-til end-of-file "vile-c-filt"
	attribute-cntl_a-sequences-til end-of-file
	~if &not %modified
	%savline goto-line
	%savcol goto-column
	write-message "[Attaching C/C++ attributes...done ]"
bind-key execute-macro-30 ^X-q

This runs vile-c-filt over the C source code. This program in turn relies upon the contents of $HOME/.vile.keywords , which specifies the attributes to provide to different text. (B for bold, U for underlined, I for italic, and C for one of 16 different colors.) This is Kevin Buettner's version:


Syntax coloring works on the X11 interface with both Versions 7.4 and 8.0 of vile . Getting it to work on a Linux console is a bit more complicated. It depends upon which screen handling interface it was compiled with.

The ncurses library

Configure vile with --with-screen=ncurses and rebuild. This will then work out of the box.

The termcap library

This is the default way that vile is configured. Using this version requires you to have a correct /etc/termcap entry for the Linux console. The following termcap entry works:[5 ]


[5] This entry courtesy of Kevin Buettner. Note that Linux distributions will vary. This was tested under Redhat Linux 4.2; you may not need to change your /etc/termcap file.

On the one hand, because syntax highlighting is accomplished with an external program, it should be possible to write any number of highlighters for different languages. On the other hand, because the facilities are rather low-level, doing so is not for non-programmers. The online help describes how the highlight filters should work.

The directory ftp://ftp.clark.net/pub/dickey/vile/utilities contains user-contributed filters for coloring makefiles, LaTeX input, Perl, HTML, and troff . It even contains a macro that will color the lines in RCS files according to their age!

Previous: 12.8 Improved Editing Facilities Learning the vi Editor Next: 12.10 Interesting Features
12.8 Improved Editing Facilities Book Index 12.10 Interesting Features

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System