Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!lll-winken!ubvax!ardent!peck!rap From: rap@peck.ardent.com (Rob Peck) Newsgroups: comp.sys.amiga Subject: Re: Editor Message-ID: <8720@ardent.UUCP> Date: 16 Oct 89 18:00:58 GMT References: <8Z=r0qy00WE501I2hz@andrew.cmu.edu> <857@lyra.stsci.edu> <11876@watcgl.waterloo.edu> <493@sagpd1.UUCP> Sender: news@ardent.UUCP Reply-To: rap@peck.ardent.com (Rob Peck) Organization: Ardent Computer Corp., Sunnyvale, CA Lines: 114 In article <493@sagpd1.UUCP> monty@sagpd1.UUCP (Monty Saine) writes: >In article <11876@watcgl.waterloo.edu> bmacintyre@watcgl.waterloo.edu (Blair MacIntyre) writes: >>In article <857@lyra.stsci.edu> levay@stsci.EDU (Zoltan Levay) writes: >>>In article <8Z=r0qy00WE501I2hz@andrew.cmu.edu>, ms0p+@andrew.cmu.edu (Michael Gordon Shapiro) writes: >> >>The undo in VI is only one level. Useful, but hardly noteworthy. To be truely > ^^^^^^^^^^^^^ > Are you talking about Stevie here or "generic" vi's. The vi on our system > supports I believe 10 (maybe 36, I can't remember now and I don't have the > manual around) levels of undo's. In other words you can recall the > last ten deletions in any order. I will give you that it is not a simple > single key stroke but the facility does exist. It will also undo undo's. > > Monty Saine The documentation that most manuals provide for vi is sadly lacking in the area of talking about the buffers. Below is an extract that describes the use of numbered buffers in vi. Yes, vi has up to a ten level undo (restoring deletes, that is). Here is a description showing how to take advantage of that. ====================================================================== Copyright 1989, Ardent Computer Corp, All Rights Reserved Extracted from "Programmer's Guide" Author: Rob Peck Using Numbered Buffers Numbered buffers hold the 9 most recently deleted blocks of text and operate as a pushdown stack, along with the unnamed buffer. As an example, if there is a deleted line currently in the unnamed buffer, and another line is deleted, then the first line is pushed into numbered buffer 1, and the unnamed buffer now has the most recently deleted line or block of text. The former contents of buffer 1 are pushed into buffer 2, the contents of 2 goes to 3 and so on, for a total of 9 numbered buffers. To reinsert any blocks of text from these buffers, you use the put command (p or P) as follows. Assume you want to restore something that you deleted three deletes ago. The unnamed buffer contains the most recent deletion, Buffer 1 the second most recent, and buffer 2 contains that third most recent deletion, the one you wish to restore. Move the cursor to the postion at which to insert the text and type: "2p The double-quote character says that you are referring to a buffer. The 2 is the number of the buffer that you are using. Finally the p is the command to put the contents into the edit buffer. The contents of all of the numbered buffers remains the same until the next delete happens, even across edit-file boundaries. An interesting trick is possible using vi's undo command. Lets say you know that what you want to insert somewhere was deleted recently (within the last 9 block deletes), but you are not quite certain which one of those deletes it was. You can use the repeat command (.) feature, along with undo, to view the contents of the numbered buffers sequentially as shown in the example here. First, issue a command that inserts the first of these numbered buffers: "1p If this is not the one you want, issue the command u. This has the same effect as though you had typed "2p. Internal to vi, the effect is to increment the buffer number, undo your original put, and try it again with the next numbered buffer. If you wish to try this command, create a text file that contains the following lines: Here is where to put the stuff 8th deleted line The bottom line Place the cursor somewhere in the first line, then enter the following command characters: dd......... (dd followed by 8 periods) This fills all 9 delete buffers, one with each sentence. Now position the cursor in the line containing the word 'Here', and issue the command: "1p It brings back the line 1st deleted line. Now issue the command: u. Each time you issue this command, the current deleted line disappears and is replaced by the next one in sequence. Whatever was the deleted block, in each case, appears in response to this command. The deleted block might contain a word, a line, or a large block of text. The only disadvantage to using the double-quote commands is that there is no user feedback provided until you complete the command. However, you can always use undo if you discover you have made a mistake. ========================================================================= Rob Peck