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