Mercurial > hg > xemacs-beta
comparison man/new-users-guide/region.texi @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children | c9fe270a4101 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 @comment node-name, next, previous, up | |
2 @node Select and Move, Search and Replace, Other Customizations, Top | |
3 @chapter Selecting and Moving Text | |
4 @cindex region | |
5 @cindex mark | |
6 | |
7 Many Emacs commands operate on an arbitrary contiguous | |
8 part of the current buffer. You can select some part of the buffer and | |
9 edit only that part of the buffer. This selected buffer is called a | |
10 @dfn{region}. You can select text in two ways: | |
11 | |
12 @itemize @bullet | |
13 @item | |
14 You use special keys to select text by defining a region between the | |
15 cursor and @dfn{the mark} (which you set). | |
16 @item | |
17 If you are running XEmacs under X, you can also select text | |
18 with the mouse. | |
19 @end itemize | |
20 | |
21 @comment node-name, next, previous, up | |
22 @menu | |
23 * Selecting Text:: Select a region of text by setting the Mark | |
24 * Mouse:: Selecting Text with Mouse | |
25 * Region Operation:: Various ways to operate on a selected text | |
26 * Moving Text:: Moving Text | |
27 * Accumulating text:: Accumulating Text from several buffers | |
28 @end menu | |
29 | |
30 @node Selecting Text, Mouse, Select and Move, Select and Move | |
31 @section Setting the Mark | |
32 @kindex C-SPC | |
33 @kindex C-x C-x | |
34 @kindex C-< | |
35 @kindex C-> | |
36 @findex set-mark-command | |
37 @findex mark-beginning-of-buffer | |
38 @findex mark-end-of-buffer | |
39 @findex exchange-point-and-mark | |
40 To define a region you need to set @dfn{the mark} at one end of it and | |
41 move the cursor to the other end. Once you set the mark, it remains | |
42 there until you set it again to some other place. Each buffer has its | |
43 own @dfn{mark ring} (a place where Emacs remembers 16 previous | |
44 locations of the mark). To set @dfn{the mark}, you can use the | |
45 following commands: | |
46 | |
47 @table @kbd | |
48 @item C-@key{SPC} | |
49 This command will set @dfn{the mark} at the position of your cursor | |
50 (@code{set-mark-command}). You can move your cursor around and @dfn{the | |
51 mark} will stay there. | |
52 @item C-x C-x | |
53 Interchange mark and point (@code{exchange-point-and-mark}). Since Emacs | |
54 will have only one cursor, after you move the cursor it will be unable | |
55 to show you where you set the @dfn{the mark}. In order to see @dfn{the | |
56 mark} you can type the command @kbd{C-x C-x} which will put your cursor | |
57 on the position of your mark and your mark on the position of your | |
58 cursor. Use the command again to reset the positions of your cursor and | |
59 mark. | |
60 @item C-< | |
61 This command will push the mark at the beginning of the buffer without | |
62 changing the position of your cursor. | |
63 @item C-> | |
64 This command will push the mark at the end of the buffer without | |
65 changing the position of your cursor. | |
66 @end table | |
67 @noindent | |
68 You can also give arguments to @kbd{C-<} or @kbd{C->}. @xref{The Mark | |
69 and the Region,,,,XEmacs User's Manual}, for more information. | |
70 | |
71 @comment node-name, next, previous, up | |
72 @node Mouse, Region Operation, Selecting Text, Select and Move | |
73 @section Selecting Text with Mouse | |
74 @cindex mouse selection | |
75 @cindex clipboard selection | |
76 @cindex primary selection | |
77 @cindex cursor shapes | |
78 If you are using XEmacs under X, you can use the mouse to select | |
79 text. The selected text will always be highlighted, so just by looking | |
80 at the text you know what you have selected so far. To select a word | |
81 just double-click with the left-mouse-button on the word. To select a | |
82 whole line triple-click anywhere on the line with the | |
83 left-mouse-button. You can also use the @b{Copy} item from the @b{Edit} | |
84 menu on the menu-bar to select text. This kind of selection is called | |
85 @b{Clipboard} selection, @xref{X Clipboard Selection,,,,XEmacs User's | |
86 Manual}, for more information. To select an arbitrary region, follow | |
87 these steps: | |
88 | |
89 @enumerate | |
90 @item | |
91 Move the mouse cursor over the character at the beginning of the region of | |
92 text you want to select. | |
93 @item | |
94 Press and hold the left mouse button. | |
95 @item | |
96 While holding the left mouse button down, drag the cursor to the | |
97 character at the end of the region of text you want to select. | |
98 @item | |
99 Release the left mouse button. | |
100 @end enumerate | |
101 The selected region of text is highlighted. | |
102 | |
103 @xref{Selecting Text with the Mouse,,,,XEmacs User's Manual}, for | |
104 more information regarding the Mouse and additional mouse operations. | |
105 | |
106 @comment node-name, next, previous, up | |
107 @node Region Operation, Moving Text, Mouse, Select and Move | |
108 @section Operating on the Region | |
109 Once you have selected a region you can do a lot of things to the text | |
110 in the region: | |
111 @kindex C-w | |
112 @kindex C-x C-u | |
113 @kindex C-x C-l | |
114 @kindex C-SPC | |
115 @kindex C-x TAB | |
116 @kindex C-M-\ | |
117 @findex print-region | |
118 @itemize @bullet | |
119 @item | |
120 Kill the text with @kbd{C-w}. For example if you want to kill a | |
121 paragraph, position the cursor to the beginning of the paragraph and | |
122 type @kbd{C-SPC}. Then go to the end of the paragraph and type | |
123 @kbd{C-w}. The entire paragraph will be deleted. You can also select the | |
124 text with a mouse and type @kbd{C-w} to kill the entire | |
125 region. @xref{Killing,,,,XEmacs User's Manual}, for more information. | |
126 | |
127 @item | |
128 Save the text in a buffer or a file (@pxref{Accumulating Text,,,,XEmacs | |
129 Manual}). | |
130 @item | |
131 You can convert the case of the text with @kbd{C-x C-l} or @kbd{C-x C-u} | |
132 If you type @kbd{C-x C-u} the selected text will become all | |
133 upper-case. If you type @kbd{C-x C-l} the selected text will become all | |
134 lower-case. | |
135 @item | |
136 Print hardcopy with @kbd{M-x print-region}. @xref{Hardcopy,,,,XEmacs | |
137 Manual}, for more information. This command will print a hardcopy of only | |
138 the selected text. | |
139 @item | |
140 Indent it with @kbd{C-x @key{TAB}} or @kbd{C-M-\} | |
141 @xref{Indentation,,,,XEmacs User's Manual}, for more information. | |
142 @end itemize | |
143 | |
144 | |
145 @comment node-name, next, previous, up | |
146 @node Moving Text, Accumulating text, Region Operation, Select and Move | |
147 @section Moving Text | |
148 @cindex yanking | |
149 @cindex pasting | |
150 @findex yank | |
151 @cindex killing | |
152 @cindex kill ring | |
153 @cindex moving text | |
154 @kindex C-y | |
155 The most common way to move or copy text in Emacs is through | |
156 @dfn{killing} or @samp{cutting} it and then @dfn{yanking} or | |
157 @samp{pasting} it. You can also use the @b{Cut} or @b{Copy} option from | |
158 the @b{Edit} menu for killing and copying respectively. @xref{Edit menu} | |
159 for reviewing the commands for killing text. All the killed text | |
160 in Emacs is recorded in the @dfn{kill ring}. Since there is only one | |
161 kill ring in Emacs, you can kill text in one buffer and yank it in | |
162 another buffer. To @samp{paste} or | |
163 @samp{yank} the killed text you can use the following commands: | |
164 @table @kbd | |
165 @item C-y | |
166 This command will yank or paste the last killed text (@code{yank}). | |
167 @item M-w | |
168 Save region as last killed text without actually killing it | |
169 (@code{copy-region-as-kill}). You can use this command to copy a | |
170 selected region and then yank (or paste) it without actually removing it | |
171 from the buffer. | |
172 @item C-M-w | |
173 Append next kill to last batch of killed text | |
174 (@code{append-next-kill}). This command will append whatever you killed | |
175 last to what you kill now. Then later you will be able to yank the | |
176 entire appended text from the @dfn{kill ring}. | |
177 @end table | |
178 | |
179 @comment node-name, next, previous, up | |
180 @node Accumulating text, , Moving Text, Select and Move | |
181 @section Accumulating Text | |
182 @findex append-to-buffer | |
183 @findex prepend-to-buffer | |
184 @findex copy-to-buffer | |
185 @findex append-to-file | |
186 @cindex copying text | |
187 @cindex accumulating text | |
188 @cindex rectangle commands | |
189 @cindex registers | |
190 @cindex temporary storage | |
191 | |
192 The following commands can be used for accumulating text from | |
193 different buffers into one place or for copying one region of text into | |
194 many buffers: | |
195 | |
196 @table @kbd | |
197 @item M-x append-to-buffer | |
198 Append region to contents of specified buffer | |
199 (@code{append-to-buffer}). After you type in this command and press | |
200 @key{RET}, Emacs will prompt you for a buffer name. You will see a | |
201 message in the echo area: | |
202 @example | |
203 Append to buffer: (default <buffer name>) | |
204 @end example | |
205 @noindent | |
206 After you type in a buffer name, a copy of the region will be inserted | |
207 at the location of the cursor into that buffer. If there is no buffer | |
208 with the name given by you, Emacs will create a new buffer with that | |
209 name. By default the cursor's position in the <buffer name> is at the end. | |
210 @item M-x prepend-to-buffer | |
211 Prepend region to contents of specified buffer. This command is similar | |
212 to the above command except that the cursor in the buffer (by default) | |
213 is at the beginning rather than at the end. | |
214 @item M-x copy-to-buffer | |
215 Copy region into specified buffer, deleting that buffer's old | |
216 contents. This command will also prompt you for a buffer name. | |
217 @item M-x insert-buffer | |
218 Insert contents of specified buffer into current buffer at point. This | |
219 command will prompt you for a buffername which you want to be copied | |
220 into the current buffer at the location of the cursor. | |
221 @item M-x append-to-file | |
222 This command will prompt you for a filename and append the region to | |
223 the end of the contents of the specified file. | |
224 @end table | |
225 | |
226 @noindent | |
227 @xref{Accumulating Text,,,,XEmacs User's Manual}, for more | |
228 information regarding this topic. | |
229 | |
230 You can also use @dfn{rectangle commands} for operating on rectangular | |
231 areas of text. @xref{Rectangles,,,,XEmacs User's Manual}, for more | |
232 information regarding rectangle commands. | |
233 | |
234 Emacs also provides @dfn{registers} which serve as temporary storage for | |
235 text or positions. Each register has a one character name and they can | |
236 store @dfn{regions}, a @dfn{rectangle}, or a @dfn{mark} i.e. a cursor | |
237 position. Whatever you store in register stays there until you store | |
238 something else in that register. To find out about commands which | |
239 manipulate registers @xref{Registers,,,,XEmacs User's Manual}. | |
240 | |
241 | |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | |
248 | |
249 | |
250 | |
251 | |
252 | |
253 | |
254 | |
255 | |
256 | |
257 |