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


11.6 GUI Interfaces

The screen shot and the explanation for this section were supplied by Bram Moolenaar. We thank him.

The vim GUI is available for UNIX, with Athena and Motif interfaces, Windows 95 and Windows NT, and BeOS. GUI versions for the Amiga, VMS, and the Macintosh are being worked on. A screen shot is shown in Figure 11.1 .

Figure 11.1: The vim GUI window

Figure 11.1

The main advantage of the GUI version is that all colors can be used, without the configuration problems that many terminal emulators have with color. The picture shows the Motif version. What you can't see in the monochrome picture are the various colors that are used to highlight items in the text. For example, the comments are blue and strings are magenta.

The GUI window contains a menu at the top, one scrollbar for each window at the right, and a scrollbar at the bottom for horizontal scrolling. Not only do the scrollbars make it easy to browse through the file, they also give an indication of the current position in the file.

The cursor is after the /free at the bottom line, which is a search command that is being typed. The cursor is bright green, and is blinking. This makes it easy to spot in between the colored text. The color and the blinking are configurable with the guicursor option. When in insert mode, the cursor changes shape to a vertical bar. In replace mode it becomes a half-height cursor. This makes it very easy to recognize the current mode.

The top window contains a shell script, the middle a Makefile , the lower a C program. They are all highlighted automatically when the file is opened. These are three of the about 70 syntaxes that are supported by the distribution (see Section 11.9.2, "Syntax Highlighting" ).

All occurrences of to in the text are highlighted with a yellow background. This is the hlsearch option in action. It shows matches of the last used search pattern. This is very useful when you are searching for the places where a variable in your source code is used. All matches are easily spotted, and the n command jumps to each next match.

The reverse video free in the top window is the current match for the search pattern that is being typed in the commandline. This shows the incsearch option in action. Each time a character is typed for the pattern, the match will be adjusted. The text is scrolled when necessary, to reveal a match further away. Using this, you can directly see where the search command is taking you, and adjust the pattern until you can see that it gets you where you wanted to go. This is especially useful in noticing typing mistakes in the pattern.

What you don't see in the picture are the file browser and dialogues, which are used when a command is selected from a menu. This is a new feature in vim Version 5.2.[1 ] For example, the File/Save as menu will pop up a file browser, where you can select the name of the file you want to write. If the file already exists, a dialogue pops up which asks you if you want to overwrite the file or not. This is much nicer than getting the Use ! to override error message. A disadvantage is that you have to grab the mouse, and thus move your hand between the keyboard and the mouse. If you don't want this, just don't use the menus. You can disable the menu (and make space for some extra text) by removing the m flag from the guioptions option.

[1] Version 5.2 is in beta release as this book goes to press. A.R.

One nice specialty of vim is that almost everything is configurable. This also includes the menus. If you don't like the menus provided, you can define your own. This works almost like defining a mapping. For example, this adds an IDE/Make-n menu, to execute the :make -n command:

:amenu IDE.Make-n :make -n<CR>

To include a dot or space in a menu name, precede it with a backslash. To get the same menu entry, but with a space before the -n :

:amenu IDE.Make\ -n  :make -n<CR>

As you can see, the backslash is not needed in the argument, only in the menu name. All this makes a nice GUI environment, while all the good old vi commands still work as in the terminal version.

The online help fully describes all of the GUI options, and how to create your own menus.


Previous: 11.5 Multiwindow Editing Learning the vi Editor Next: 11.7 Extended Regular Expressions
11.5 Multiwindow Editing Book Index 11.7 Extended Regular Expressions

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