12.8. Improved Editing FacilitiesThis section describes the features of vile that make simple text editing easier and more powerful. 12.8.1. Command-Line History and Completionvile stores all your ex commands in a buffer named [History]. This feature is controlled with the history option, which is true by default. Turning it off disables the history feature and removes the [History] buffer. The command show-history will split the screen and display the [History] buffer in a new window. Starting with vile 7.4, the colon command line is really a minibuffer. You can use it to recall lines from the [History] buffer and edit them. You use the and keys to scroll backward and forward in the history, and and to move around within the line. Your current delete character (usually BACKSPACE) can be used to delete characters. Any other characters you type will be inserted at the current cursor postion. You can toggle the minibuffer into vi mode by typing the mini-edit character (by default, ^G). When you do this, vile will highlight the minibuffer using the mechanism specified by the mini-hilite option. The default is reverse, for reverse video. In vi mode, you can use vi style commands for positioning. In Version 8.0, you can also use the i, I, a, and A vi commands. An interesting feature is that vile will use the history to show you previous data that corresponds to the command you're entering. For instance, after typing :set followed by a space, vile will prompt you with Global value:. At that point, you can use to see previous global variables that you've set, should you wish to change one of them. The ex command line provides completion of various sorts. As you type the name of a command, you can hit the TAB key at any point. vile will fill out the rest of the command name as much as possible. If you type a TAB a second time, vile will create a new window showing you all the possible completions. Completion applies to built-in and user-defined vile commands, tags, filenames, modes (described later in this chapter), variables, and to the terminal characters (the character settings such as backspace, suspend, and so on, derived from your stty settings). As a side point, this leads to an interesting phenomenon. In vi-style editors, commands may have long names, but they tend to be unique in the first few characters, since abbreviations are accepted. In emacs-style editors, command names often are not unique in the first several characters, but command completion still allows you to get away with less typing. 12.8.2. Tag StacksTag stacking is described in Section 8.5.3. In vile, tag stacking is available and straightforward. It is somewhat different than the other clones, most notably in the vi mode commands that are used for tag searching and popping the tag stack. Table 12.2 shows the vile tag commands. Table 12.2. vile Tag Commands
The vi mode commands are described in Table 12.3. Table 12.3. vile Command Mode Tag Commands
As in the other editors, options control how vile manages the tag related commands, as shown in Table 12.4. Table 12.4. vile Options for Tag Management
12.8.3. Infinite Undovile is similar in principle but different in practice from the other editors. Like elvis and vim, there is an undo limit you can set, but like nvi, the . command will do the next undo or redo, as appropriate it. Separate vi mode commands implement successive undo and redo. vile uses the undolimit option to control how many changes it will store. The default is 10, meaning that you can undo up to the 10 most recent changes. Setting it to zero allows true "infinite undo," but this may consume a lot of memory. To start an undo, first use either the u or ^X u commands. Then each successive . command will do another undo. Like vi, two u commands just toggle the state of the change; however, each ^X u command does another undo. The ^X r command does a redo. Typing . after the first ^X r will do successive redos. You can provide a count to the ^X u and ^X r commands, in which case vile will perform the requested number of undos or redos. 12.8.4. Arbitrary Length Lines and Binary Datavile can edit files with arbitrary length lines, and with an arbitrary number of lines. vile automatically handles binary data. No special command lines or options are required. To enter 8-bit text, type ^V followed by an x and two hexadecimal digits, or a 0 and three octal digits, or three decimal digits. 12.8.5. Incremental SearchingAs mentioned in Section 8.6.4, you perform incremental searching in vile using the ^X S and ^X R commands. It is not necessary to set an option to enable incremental searching. The cursor moves through the file as you type, always being placed on the first character of the text that matches. ^X S incrementally searches forward through the file, while ^X R incrementally searches backwards. You may wish to add these commands (described below) to your .vilerc file to make the more familiar / and ? search commands work incrementally: bind-key incremental-search / bind-key reverse-incremental-search ? Also of interest is the "visual match" facility, which will highlight all occurrences of the matched expression. For a .vilerc file: set visual-matches reverse This command directs vile to use reverse video for visual matching. Since the highlighting can sometimes be visually distracting, the = command will turn off any current highlighting until you enter a new search pattern. 12.8.6. Left-Right ScrollingAs mentioned in Section 8.6.5 in Chapter 8, you enable left-right scrolling in vile using :set nolinewrap. Unlike the other editors, left-right scrolling is the default. Long lines are marked at the left and right edges with < and >. The value of sideways controls the number of characters by which vile shifts the screen when scrolling left to right. With sideways set to zero, each scroll moves the screen by one third. Otherwise the screen scrolls by the desired number of characters. 12.8.7. Visual Modevile is different from elvis and vim in the way you highlight the text you want to operate on. It uses the "quoted motion" command, q. You enter q at the beginning of the region, any other vi motions to get to the opposite end of the region, and then another q to end the quoted motion. vile highlights the marked text. Arguments to the q command determine what kind of highlighting it will do. 1q (same as q) does an exact highlighting, 2q does line-at-a-time highlighting, and 3q does rectangular highlighting. Typically, you use a quoted motion in conjunction with an operator, such as d or y. Thus, d3qjjwq deletes the rectangle indicated by the motions. When used without an operator, the region is left highlighted. It can be referred to later using ^S. Thus, d ^S will delete the highlighted region. In addition, rectangular regions can be indicated through the use of marks.[61] As you know, a mark can be used to refer to either a specific character (when referred to with `) or a specific line (when referred to with '). In addition, referring to the mark (say a mark set with mb) with `b instead of 'b can change the nature of the operation being done—d'b will delete a set of lines, and d`b will delete two partial lines and the lines in between. Using the ` form of mark reference gives a more "exact" region than the ' form of mark reference.
vile adds a third form of mark reference. The \ command can be used as another way of referring to a mark. By itself, it behaves just like ` and moves the cursor to the character at which the mark was set. When combined with an operator, however, the behavior is quite different. The mark reference becomes "rectangular," such that the action d\b will delete the rectangle of characters whose corners are marked by the cursor and the character which holds mark b.
The commands which define arbitrary regions and operate upon them are summarized in Table 12.5. Table 12.5. vile Block Mode Operations
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
||||||||||||||||||||||||||||||||||||||||||||||||||
|