VI Editor 6'th Edition

Page 205

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). 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.


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.