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


Book HomeLearning the vi EditorSearch this book

10.8. Improved Editing Facilities

This section describes the features of elvis that make simple text editing easier and more powerful.

10.8.2. Tag Stacks

Tag stacking is described in Section 8.5.3. In elvis, tag stacking is very straightforward, as shown in Table 10.5 and Table 10.6.

Table 10.5. elvis Tag Commands

Command Function
ta[g][!] [tagstring]

Edit the file containing tagstring as defined in the tags file. The ! forces elvis to switch to the new file if the current buffer has been modified but not saved.

stac[k]

Display the current tag stack.

po[p][!]

Pop a cursor position off the stack, restoring the cursor to its previous position.

Table 10.6. elvis Command Mode Tag Commands

Command Function
^]

Look up the location of the identifier under the cursor in the tags file, and move to that location. The current location is automatically pushed onto the tag stack.

^T

Return to the previous location in the tag stack, i.e., pop off one element.

Unlike traditional vi, when you type ^], elvis looks up the entire word containing the cursor, not just the part of the word from the cursor location forward.

In HTML mode (discussed in Section 10.10.1), the commands all work the same except that :tag expects to be given a URL instead of a tag name. URLs don't depend on having a tags file, so the tags file is ignored when in HTML mode. elvis 2.0 doesn't support any network protocols,[54] so its URLs can only consist of a file name and/or an HTML #label.

[54]This is no longer true in elvis 2.1; see Section 10.11 for details.

Several :set options affect how elvis works with tags, as described in Table 10.7.

Table 10.7. elvis Options for Tag Management

Option Function
taglength, tl

Control the number of significant characters in a tag that is to be looked up. The default value of zero indicates that all characters are significant.

tags, tagpath

The value is a list of directory and/or filenames in which to look for tags files. elvis looks for a file named tags in any entry that is a directory. Entries in the list are colon-separated (or semicolon on DOS/Windows), in order to allow spaces in directory names. The default value is just "tags", which looks for a file named tags in the current directory. This can be overridden by setting the TAGPATH environment variable.

tagstack

When set to true, elvis stacks each location on the tag stack. Use :set notagstack to disable tag stacking.

Version 2.1 of elvis (in beta test as of this writing) supports the extended tags file format described earlier. elvis comes with its own version of ctags. The version in elvis 2.1 generates the enhanced format described earlier. Here is an example of the special !_TAG_ lines it produces:

!_TAG_FILE_FORMAT       2       /supported features/
!_TAG_FILE_SORTED       1       /0=unsorted, 1=sorted/
!_TAG_PROGRAM_AUTHOR    Steve Kirkendall        /kirkenda@cs.pdx.edu/
!_TAG_PROGRAM_NAME      Elvis Ctags     //
!_TAG_PROGRAM_URL       ftp://ftp.cs.pdx.edu/pub/elvis/README.html  //
!_TAG_PROGRAM_VERSION   2.1     //

Finally, in elvis, each window has its own tag stack.

10.8.6. Visual Mode

elvis allows you to select regions one character at a time, one line at a time, or rectangularly, using the commands shown in Table 10.8.

Table 10.8. elvis Block Mode Command Characters

Command Function
v

Start region selection, character at a time mode.

V

Start region selection, line at a time mode.

^V

Start region selection, rectangular mode.

elvis highlights (using reverse video) the text as you are selecting. To make your selection, simply use the normal motion keys. The screen below shows a rectangular region:


The 6th edition of <citetitle>Learning the vi Editor</citetitle>
brings the book into the late 1990&rsquo;s.


In particular, besides the &ldquo;original&rdquo; version of


<command>vi</command> that comes as a standard part of every UNIX


 
system, there are now a number of freely available &ldquo;clones&rdquo;
or work-alike editors.

elvis only permits a few operations on selected areas of text. Some operations work only on whole lines, even if you've selected a region that does not contain whole lines (see Table 10.9).

Table 10.9. elvis Block Mode Operations

Command Operation
c, d, y

Change, delete, or yank text. Only d works exactly on rectangles.

<, >, !

Shift text left or right, filter text. These operate on the whole lines containing the marked region.

After using the d command to delete the region, the screen now looks like this:

The 6th edition of <citetitle>Learning the vi Editor</citetitle>
brings the 90&rsquo;s.
In particulo;original&rdquo; version of
<command>vi as a standard part of every
system, there are n available &ldquo;clones&rdquo;
or work-alike editors.


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.