10.8. Improved Editing FacilitiesThis section describes the features of elvis that make simple text editing easier and more powerful. 10.8.1. Command-Line History and CompletionEverything you type on the ex command line is saved in a buffer named Elvis ex history. This is accessible like any other elvis buffer, but is not directly useful when just viewed in a window. In order to access the history, you use the arrow keys on your terminal to display previous commands and to edit them. Use and to page through the list, and and to move around on a command line. You can insert characters by typing and erase them by backspacing over them. Much as when editing in a regular vi buffer, the backspace does remove the characters, but the line is not updated as you type, so be careful! When entering text into the Elvis ex history buffer (i.e., on the colon command line), the TAB key can be used for filename expansion. The preceding word is assumed to be a partial filename, and elvis searches for all matching files. If there are multiple matches, it fills in as many characters of the name as possible, and then beeps; or, if no additional characters are implied by the matching filenames, elvis lists all matching names and redisplays the command line. If there is a single match, elvis completes the name and appends a tab character. If there are no matches, elvis simply inserts a tab character. To get a real tab character, precede it with a ^V. You can also disable filename completion entirely by setting the Elvis ex history buffer's inputtab option to tab, via the following command: :(Elvis ex history)set inputtab=tab 10.8.2. Tag StacksTag 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 CommandsTable 10.6. elvis Command Mode Tag Commands
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.
Several :set options affect how elvis works with tags, as described in Table 10.7. Table 10.7. elvis Options for Tag Management
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.3. Infinite UndoWith elvis, before being able to undo and redo multiple levels of changes, you must first set the undolevels option to the number of levels of "undo" that elvis should allow. A negative value disallows any undoing (which is not terribly useful). The elvis documentation warns that each level of undo uses around 6K bytes of the session file (the file that describes your editing session), and thus can eat up disk space rather quickly. It recommends not setting undolevels any higher than 100 and "probably much lower." Once you've set undolevels to a non-zero value, you enter text as normal. Then each successive u command undoes one change. To redo (undo the undo), you use the (rather mnemonic) CTRL-R command. In elvis, the default value of undolevels is zero, which causes elvis to mimic UNIX vi. The option applies per buffer being edited; see Section 10.4.2 for a description of how to set it for every file that you edit. Once undolevels has been set, a count to either the u or ^R commands undoes or redoes the given number of changes. 10.8.4. Arbitrary Length Lines and Binary Dataelvis can edit files with arbitrary length lines, and with an arbitrary number of lines. Under UNIX, elvis does not treat a binary file differently from any other file. On other systems, it uses the elvis.brf file to set the binary option. This avoids newline translation issues. You can enter eight-bit text by typing ^X followed by two hexadecimal digits. Using the hex display mode is an excellent way to edit binary files. (The elvis.brf file and the hex display mode are described in Section 10.10.) 10.8.5. Left-Right ScrollingAs mentioned in Section 8.6.4, you enable left-right scrolling in elvis using :set nowrap. The value of sidescroll controls the number of characters by which elvis shifts the screen when scrolling left to right. The ^W S command toggles the value of this option. 10.8.6. Visual Modeelvis 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
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’s. In particular, besides the “original” version of <command>vi</command> that comes as a standard part of every UNIX system, there are now a number of freely available “clones” 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
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’s. In particulo;original” version of <command>vi as a standard part of every system, there are n available “clones” or work-alike editors. Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|