Next: , Previous: , Up: Improvements over Vi   [Contents][Index]

2.6 Improved Search

Viper provides buffer search, the ability to search the buffer for a region under the cursor. You have to turn this on in your Viper customization file either by calling


or by setting viper-buffer-search-char to, say, f3:

(setq viper-buffer-search-char ?g)

If the user calls viper-buffer-search-enable explicitly (the first method), then viper-buffer-search-char will be set to g. Regardless of how this feature is enabled, the key viper-buffer-search-char will take movement commands, like w,/,e, to find a region and then search for the contents of that region. This command is very useful for searching for variable names, etc., in a program. The search can be repeated by n or reversed by N.

Emacs provides incremental search. As you type the string in, the cursor will move to the next match. You can snarf words from the buffer as you go along. Incremental Search is normally bound to C-s and C-r. See Customization, to find out how to change the bindings of C-r or C-s. For details, see Incremental Search in The GNU Emacs Manual.

Viper also provides a query replace function that prompts through the minibuffer. It is invoked by the Q key in Vi state.

On a window display, Viper supports mouse search, i.e., you can search for a word by clicking on it. See Viper Specials, for details.

Finally, on a window display, Viper highlights search patterns as it finds them. This is done through what is known as faces in Emacs. The variable that controls how search patterns are highlighted is viper-search-face. If you don’t want any highlighting at all, put

(copy-face 'default 'viper-search-face)

in your Viper customization file. If you want to change how patterns are highlighted, you will have to change viper-search-face to your liking. The easiest way to do this is to use Emacs customization widget, which is accessible from the menubar. Viper customization group is located under the Emulations customization group, which in turn is under the Editing group (or simply by typing :customize). All Viper faces are grouped together under Viper’s Highlighting group.

Try it: it is really simple!

Next: , Previous: , Up: Improvements over Vi   [Contents][Index]