Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | .Go 6 "CUT BUFFERS" |
2 | .PP | |
3 | When \*E deletes text, it stores that text in a cut buffer. | |
4 | This happens in both visual mode and EX mode. | |
5 | There is no practical limit to how much text a cut buffer can hold. | |
6 | .PP | |
7 | There are 36 cut buffers: | |
8 | 26 named buffers ("a through "z), | |
9 | 9 anonymous buffers ("1 through "9), | |
10 | and 1 extra cut buffer (".). | |
11 | .PP | |
12 | In EX mode, the :move and :copy commands use a cut buffer to temporarily | |
13 | hold the text to be moved/copied. | |
14 | .NH 2 | |
15 | Putting text into a Cut Buffer | |
16 | .PP | |
17 | In visual mode, text is copied into a cut buffer when you use the | |
18 | d, y, c, C, s, or x commands. | |
19 | There are also a few others. | |
20 | .PP | |
21 | By default, the text goes into the "1 buffer. | |
22 | The text that used to be in "1 gets shifted into "2, | |
23 | "2 gets shifted into "3, and so on. | |
24 | The text that used to be in "9 is lost. | |
25 | This way, the last 9 things you deleted are still accessible. | |
26 | .PP | |
27 | You can also put the text into a named buffer -- "a through "z. | |
28 | To do this, you should type the buffer's name | |
29 | (two keystrokes: a double-quote and a lowercase letter) | |
30 | before the command that will cut the text. | |
31 | When you do this, "1 through "9 are not affected by the cut. | |
32 | .PP | |
33 | You can append text to one of the named buffers. | |
34 | To do this, type the buffer's name in uppercase | |
35 | (a double-quote and an uppercase letter) | |
36 | before the d/y/c/C/s/x command. | |
37 | .PP | |
38 | The ". buffer is special. | |
39 | It isn't affected by the d/y/c/C/s/x command. | |
40 | Instead, it stores the text that you typed in | |
41 | the last time you were in input mode. | |
42 | It is used to implement the . visual command, | |
43 | and ^A in input mode. | |
44 | .PP | |
45 | In EX mode (also known as colon mode), | |
46 | the :delete, :change, and :yank commands all copy text into a cut buffer. | |
47 | Like the visual commands, these EX commands normally use the "1 buffer, | |
48 | but you can use one of the named buffers by giving its name after the command. | |
49 | For example, | |
50 | .sp 1 | |
51 | .ti +0.5i | |
52 | :20,30y a | |
53 | .sp | |
54 | .LP | |
55 | will copy lines 20 through 30 into cut buffer "a. | |
56 | .PP | |
57 | You can't directly put text into the ". buffer, or the "2 through "9 buffers. | |
58 | .NH 2 | |
59 | Pasting from a Cut Buffer | |
60 | .PP | |
61 | There are two styles of pasting: | |
62 | line-mode and character-mode. | |
63 | If a cut buffer contains whole lines (from a command like "dd") | |
64 | then line-mode pasting is used; | |
65 | if it contains partial lines (from a command like "dw") | |
66 | then character-mode pasting is used. | |
67 | The EX commands always cut whole lines. | |
68 | .PP | |
69 | Character-mode pasting causes the text to be inserted into the line that | |
70 | the cursor is on. | |
71 | .PP | |
72 | Line-mode pasting inserts the text on a new line above or below the line | |
73 | that the cursor is on. | |
74 | It doesn't affect the cursor's line at all. | |
75 | .PP | |
76 | In visual mode, the p and P commands insert text from a cut buffer. | |
77 | Uppercase P will insert it before the cursor, | |
78 | and lowercase p will insert it after the cursor. | |
79 | Normally, these commands will paste from the "1 buffer, but you can | |
80 | specify any other buffer to paste from. | |
81 | Just type its name (a double-quote and another character) | |
82 | before you type the P or p. | |
83 | .PP | |
84 | In EX mode, the (pu)t command pastes text after a given line. | |
85 | To paste from a buffer other that "1, | |
86 | enter its name after the command. | |
87 | .NH 2 | |
88 | Macros | |
89 | .PP | |
90 | The contents of a named cut buffer can be executed as a series of | |
91 | ex/vi commands. | |
92 | .PP | |
93 | To put the instructions into the cut buffer, you must first insert | |
94 | them into the file, and then delete them into a named cut buffer. | |
95 | .PP | |
96 | To execute a cut buffer's contents as EX commands, | |
97 | you should give the EX command "@" and the name of the buffer. | |
98 | For example, :@z will execute "z as a series of EX commands. | |
99 | .PP | |
100 | To execute a cut buffer's contents as visual commands, | |
101 | you should give the visual command "@" and the letter of the buffer's name. | |
102 | The visual "@" command is different from the EX "@" command. | |
103 | They interpret the cut buffer's contents differently. | |
104 | .PP | |
105 | The visual @ command can be rather finicky. | |
106 | Each character in the buffer is interpretted as a keystroke. | |
107 | If you load the instructions into the cut buffer via a "zdd command, | |
108 | then the newline character at the end of the line will be executed just | |
109 | like any other character, so the cursor would be moved down 1 line. | |
110 | If you don't want the cursor to move down 1 line at the end of each | |
111 | @z command, then you should load the cut buffer by saying 0"zD instead. | |
112 | .PP | |
113 | Although cut buffers can hold any amount of text, | |
114 | \*E can only \fIexecute\fR small buffers. | |
115 | The size limit is roughly 1000 characters, for either EX macros or VI macros. | |
116 | If a buffer is too large to execute, an error message is displayed. | |
117 | .PP | |
118 | You can't nest :@ commands. | |
119 | You can't run :@ commands from your .exrc file, | |
120 | or any other :source file either. | |
121 | Similarly, you can't run a :source command from within an @ command. | |
122 | Hopefully, these restrictions will be lifted in a later version. | |
123 | .NH 2 | |
124 | The Effect of Switching Files | |
125 | .PP | |
126 | When \*E first starts up, all cut buffers are empty. | |
127 | When you switch to a different file | |
128 | (via the :n or :e commands perhaps) | |
129 | the 9 anonymous cut buffers are emptied again, | |
130 | but the other 27 buffers ("a through "z, and ".) retain their text. |