1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
3 @c 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
6 @node Killing, Yanking, Mark, Top
7 @chapter Killing and Moving Text
13 @dfn{Killing} means erasing text and copying it into the @dfn{kill
14 ring}, from which you can bring it back into the buffer by
15 @dfn{yanking} it. (Some applications use the terms ``cutting'' and
16 ``pasting'' for similar operations.) This is the most common way of
17 moving or copying text within Emacs. It is very versatile, because
18 there are commands for killing many different types of syntactic
22 @section Deletion and Killing
28 Most commands which erase text from the buffer save it in the kill
29 ring. These are known as @dfn{kill} commands. The kill ring stores
30 several recent kills, not just the last one, so killing is a very safe
31 operation: when you make a new kill, you don't have to worry much
32 about losing text that you previously killed.
34 You can yank text from the kill ring into any position in a buffer,
35 including a position in a different buffer; the kill ring is shared by
36 all buffers. The @kbd{C-/} (@code{undo}) command can undo both kill
37 and delete commands (@pxref{Undo}); the importance of the kill ring is
38 that you can yank the text in a different place.
40 Commands that erase text but do not save it in the kill ring are
41 known as @dfn{delete} commands. These include @kbd{C-d}
42 (@code{delete-char}) and @key{DEL} (@code{delete-backward-char}),
43 which delete only one character at a time, and those commands that
44 delete only spaces or newlines. Commands that can erase significant
45 amounts of nontrivial data generally do a kill operation instead. The
46 commands' names and individual descriptions use the words @samp{kill}
47 and @samp{delete} to say which kind of operation they perform.
49 You can also use the mouse to kill and yank. @xref{Cut and Paste}.
52 * Deletion:: Commands for deleting small amounts of text and
54 * Killing by Lines:: How to kill entire lines of text at one time.
55 * Other Kill Commands:: Commands to kill large regions of text and
56 syntactic units such as words and sentences.
57 * Kill Options:: Options that affect killing.
62 @findex delete-backward-char
65 Deletion means erasing text and not saving it in the kill ring. For
66 the most part, the Emacs commands that delete text are those that
67 erase just one character or only whitespace.
72 Delete next character (@code{delete-char}).
74 @itemx @key{Backspace}
75 Delete previous character (@code{delete-backward-char}).
77 Delete spaces and tabs around point (@code{delete-horizontal-space}).
79 Delete spaces and tabs around point, leaving one space
80 (@code{just-one-space}).
82 Delete blank lines around the current line (@code{delete-blank-lines}).
84 Join two lines by deleting the intervening newline, along with any
85 indentation following it (@code{delete-indentation}).
88 We have already described the basic deletion commands @kbd{C-d}
89 (@code{delete-char}) and @key{DEL} (@code{delete-backward-char}).
93 @findex delete-horizontal-space
95 @findex just-one-space
96 The other delete commands are those that delete only whitespace
97 characters: spaces, tabs and newlines. @kbd{M-\}
98 (@code{delete-horizontal-space}) deletes all the spaces and tab
99 characters before and after point. With a prefix argument, this only
100 deletes spaces and tab characters before point. @kbd{M-@key{SPC}}
101 (@code{just-one-space}) does likewise but leaves a single space after
102 point, regardless of the number of spaces that existed previously
103 (even if there were none before). With a numeric argument @var{n}, it
104 leaves @var{n} spaces after point.
106 @kbd{C-x C-o} (@code{delete-blank-lines}) deletes all blank lines
107 after the current line. If the current line is blank, it deletes all
108 blank lines preceding the current line as well (leaving one blank line,
109 the current line). On a solitary blank line, it deletes that line.
111 @kbd{M-^} (@code{delete-indentation}) joins the current line and the
112 previous line, by deleting a newline and all surrounding spaces, usually
113 leaving a single space. @xref{Indentation,M-^}.
115 @node Killing by Lines
116 @subsection Killing by Lines
120 Kill rest of line or one or more lines (@code{kill-line}).
122 Kill an entire line at once (@code{kill-whole-line})
127 The simplest kill command is @kbd{C-k}. If given at the beginning
128 of a line, it kills all the text on the line@footnote{Here, ``line''
129 means a logical text line, not a screen line. @xref{Continuation
130 Lines}.}, leaving it blank. When used on a blank line, it kills the
131 whole line including its newline.
133 More precisely, @kbd{C-k} kills from point up to the end of the
134 line, unless it is at the end of a line. In that case it kills the
135 newline following point, thus merging the next line into the current
136 one. Spaces and tabs at the end of the line are ignored when deciding
137 which case applies, so as long as point is after the last visible
138 character in the line, you can be sure that @kbd{C-k} will kill the
139 newline. To kill an entire non-blank line, go to the beginning and
140 type @kbd{C-k} twice.
142 When @kbd{C-k} is given a positive argument @var{n}, it kills
143 @var{n} lines and the newlines that follow them (text on the current
144 line before point is not killed). With a negative argument
145 @minus{}@var{n}, it kills @var{n} lines preceding the current line,
146 together with the text on the current line before point. @kbd{C-k}
147 with an argument of zero kills the text before point on the current
150 @vindex kill-whole-line
151 If the variable @code{kill-whole-line} is non-@code{nil}, @kbd{C-k} at
152 the very beginning of a line kills the entire line including the
153 following newline. This variable is normally @code{nil}.
155 @kindex C-S-backspace
156 @findex kill-whole-line
157 @kbd{C-S-backspace} (@code{kill-whole-line}) will kill a whole line
158 including its newline regardless of the position of point within the
159 line. Note that many character terminals will prevent you from typing
160 the key sequence @kbd{C-S-backspace}.
162 @node Other Kill Commands
163 @subsection Other Kill Commands
169 Kill region (@code{kill-region}). @xref{Mark}.
171 Save region as last killed text without actually killing it
172 (@code{kill-ring-save}). Some programs call this ``copying.''
174 Kill word (@code{kill-word}). @xref{Words}.
176 Kill word backwards (@code{backward-kill-word}).
178 Kill back to beginning of sentence (@code{backward-kill-sentence}).
181 Kill to end of sentence (@code{kill-sentence}).
183 Kill the following balanced expression (@code{kill-sexp}). @xref{Expressions}.
185 Kill through the next occurrence of @var{char} (@code{zap-to-char}).
188 Apart from @kbd{C-k}, the most commonly-used kill command is
189 @kbd{C-w} (@code{kill-region}), which kills the text in the region
190 (i.e., between point and mark). @xref{Mark}. If the mark is inactive
191 when you type @kbd{C-w}, it first reactivates the mark where it was
192 last set. The mark is deactivated at the end of the command.
195 @findex kill-ring-save
196 The command @kbd{M-w} (@code{kill-ring-save}) copies the region into
197 the kill ring without removing it from the buffer. This is
198 approximately equivalent to @kbd{C-w} followed by @kbd{C-/}, except
199 that @kbd{M-w} does not alter the undo history.
201 Emacs also provides commands to kill specific syntactic units:
202 words, with @kbd{M-@key{DEL}} and @kbd{M-d} (@pxref{Words}); balanced
203 expressions, with @kbd{C-M-k} (@pxref{Expressions}); and sentences,
204 with @kbd{C-x @key{DEL}} and @kbd{M-k} (@pxref{Sentences}).
208 The command @kbd{M-z} (@code{zap-to-char}) combines killing with
209 searching: it reads a character and kills from point up to (and
210 including) the next occurrence of that character in the buffer. A
211 numeric argument acts as a repeat count; a negative argument means to
212 search backward and kill text before point.
215 @subsection Options for Killing
217 @vindex kill-read-only-ok
218 @cindex read-only text, killing
219 Some specialized buffers contain @dfn{read-only text}, which cannot
220 be modified and therefore cannot be killed. But some users like to
221 use the kill commands to copy read-only text into the kill ring,
222 without actually changing it. Therefore, the kill commands work
223 specially in a read-only buffer: they move over text, and copy it to
224 the kill ring, without actually deleting it from the buffer.
225 Normally, kill commands beep and display an error message when this
226 happens. But if you set the variable @code{kill-read-only-ok} to a
227 non-@code{nil} value, they just print a message in the echo area to
228 explain why the text has not been erased.
230 @vindex kill-do-not-save-duplicates
231 If you change the variable @code{kill-do-not-save-duplicates} to a
232 non-@code{nil} value, identical subsequent kills yield a single
233 kill-ring entry, without duplication.
235 @node Yanking, Accumulating Text, Killing, Top
243 @dfn{Yanking} means reinserting text previously killed. The usual
244 way to move or copy text is to kill it and then yank it elsewhere one
249 Yank last killed text (@code{yank}).
251 Replace text just yanked with an earlier batch of killed text
254 Append next kill to last batch of killed text (@code{append-next-kill}).
257 On graphical displays with window systems, if there is a current
258 selection in some other application, and you selected it more recently
259 than you killed any text in Emacs, @kbd{C-y} copies the selection
260 instead of text killed within Emacs.
263 * Kill Ring:: Where killed text is stored. Basic yanking.
264 * Appending Kills:: Several kills in a row all yank together.
265 * Earlier Kills:: Yanking something killed some time ago.
269 @subsection The Kill Ring
271 All killed text is recorded in the @dfn{kill ring}, a list of blocks
272 of text that have been killed. There is only one kill ring, shared by
273 all buffers, so you can kill text in one buffer and yank it in another
274 buffer. This is the usual way to move text from one file to another.
275 (There are several other methods: for instance, you could store the
276 text in a register. @xref{Registers}, for information about
277 registers. @xref{Accumulating Text}, for some other ways to move text
282 The command @kbd{C-y} (@code{yank}) reinserts the text of the most
283 recent kill, leaving the cursor at the end of the text. It also adds
284 the position of the beginning of the text to the mark ring, without
285 activating the mark; this allows you to jump easily to that position
286 with @kbd{C-x C-x} (@pxref{Setting Mark}). With a plain prefix
287 argument (@kbd{C-u C-y}), it instead leaves the cursor in front of the
288 text, and adds the position of the end of the text to the mark ring.
289 Using other sort of prefix argument specifies an earlier kill; for
290 example, @kbd{C-u 4 C-y} reinserts the fourth most recent kill.
291 @xref{Earlier Kills}.
293 @cindex yanking and text properties
294 @vindex yank-excluded-properties
295 The yank commands discard certain properties from the yanked text.
296 These are properties that might lead to annoying results, such as
297 causing the text to respond to the mouse or specifying key bindings.
298 The list of properties to discard is stored in the variable
299 @code{yank-excluded-properties}. Yanking of register contents and
300 rectangles also discard these properties. @xref{Text Properties,,,
301 elisp, the Emacs Lisp Reference Manual}, for more information about
304 @node Appending Kills
305 @subsection Appending Kills
307 @cindex appending kills in the ring
308 Normally, each kill command pushes a new entry onto the kill ring.
309 However, two or more kill commands in a row combine their text into a
310 single entry, so that a single @kbd{C-y} yanks all the text as a unit,
311 just as it was before it was killed.
313 Thus, if you want to yank text as a unit, you need not kill all of it
314 with one command; you can keep killing line after line, or word after
315 word, until you have killed it all, and you can still get it all back at
318 Commands that kill forward from point add onto the end of the previous
319 killed text. Commands that kill backward from point add text onto the
320 beginning. This way, any sequence of mixed forward and backward kill
321 commands puts all the killed text into one entry without rearrangement.
322 Numeric arguments do not break the sequence of appending kills. For
323 example, suppose the buffer contains this text:
326 This is a line @point{}of sample text.
330 with point shown by @point{}. If you type @kbd{M-d M-@key{DEL} M-d
331 M-@key{DEL}}, killing alternately forward and backward, you end up with
332 @samp{a line of sample} as one entry in the kill ring, and @samp{This
333 is@ @ text.} in the buffer. (Note the double space between @samp{is}
334 and @samp{text}, which you can clean up with @kbd{M-@key{SPC}} or
337 Another way to kill the same text is to move back two words with
338 @kbd{M-b M-b}, then kill all four words forward with @kbd{C-u M-d}.
339 This produces exactly the same results in the buffer and in the kill
340 ring. @kbd{M-f M-f C-u M-@key{DEL}} kills the same text, all going
341 backward; once again, the result is the same. The text in the kill ring
342 entry always has the same order that it had in the buffer before you
346 @findex append-next-kill
347 If a kill command is separated from the last kill command by other
348 commands (not just numeric arguments), it starts a new entry on the kill
349 ring. But you can force it to append by first typing the command
350 @kbd{C-M-w} (@code{append-next-kill}) right before it. The @kbd{C-M-w}
351 tells the following command, if it is a kill command, to append the text
352 it kills to the last killed text, instead of starting a new entry. With
353 @kbd{C-M-w}, you can kill several separated pieces of text and
354 accumulate them to be yanked back in one place.@refill
356 A kill command following @kbd{M-w} (@code{kill-ring-save}) does not
357 append to the text that @kbd{M-w} copied into the kill ring.
360 @subsection Yanking Earlier Kills
362 @cindex yanking previous kills
365 To recover killed text that is no longer the most recent kill, use the
366 @kbd{M-y} command (@code{yank-pop}). It takes the text previously
367 yanked and replaces it with the text from an earlier kill. So, to
368 recover the text of the next-to-the-last kill, first use @kbd{C-y} to
369 yank the last kill, and then use @kbd{M-y} to replace it with the
370 previous kill. @kbd{M-y} is allowed only after a @kbd{C-y} or another
373 You can understand @kbd{M-y} in terms of a ``last yank'' pointer which
374 points at an entry in the kill ring. Each time you kill, the ``last
375 yank'' pointer moves to the newly made entry at the front of the ring.
376 @kbd{C-y} yanks the entry which the ``last yank'' pointer points to.
377 @kbd{M-y} moves the ``last yank'' pointer to a different entry, and the
378 text in the buffer changes to match. Enough @kbd{M-y} commands can move
379 the pointer to any entry in the ring, so you can get any entry into the
380 buffer. Eventually the pointer reaches the end of the ring; the next
381 @kbd{M-y} loops back around to the first entry again.
383 @kbd{M-y} moves the ``last yank'' pointer around the ring, but it does
384 not change the order of the entries in the ring, which always runs from
385 the most recent kill at the front to the oldest one still remembered.
387 @kbd{M-y} can take a numeric argument, which tells it how many entries
388 to advance the ``last yank'' pointer by. A negative argument moves the
389 pointer toward the front of the ring; from the front of the ring, it
390 moves ``around'' to the last entry and continues forward from there.
392 Once the text you are looking for is brought into the buffer, you can
393 stop doing @kbd{M-y} commands and it will stay there. It's just a copy
394 of the kill ring entry, so editing it in the buffer does not change
395 what's in the ring. As long as no new killing is done, the ``last
396 yank'' pointer remains at the same place in the kill ring, so repeating
397 @kbd{C-y} will yank another copy of the same previous kill.
399 If you know how many @kbd{M-y} commands it would take to find the
400 text you want, you can yank that text in one step using @kbd{C-y} with
401 a numeric argument. @kbd{C-y} with an argument restores the text from
402 the specified kill ring entry, counting back from the most recent as
403 1. Thus, @kbd{C-u 2 C-y} gets the next-to-the-last block of killed
404 text---it is equivalent to @kbd{C-y M-y}. @kbd{C-y} with a numeric
405 argument starts counting from the ``last yank'' pointer, and sets the
406 ``last yank'' pointer to the entry that it yanks.
408 @vindex kill-ring-max
409 The length of the kill ring is controlled by the variable
410 @code{kill-ring-max}; no more than that many blocks of killed text are
414 The actual contents of the kill ring are stored in a variable named
415 @code{kill-ring}; you can view the entire contents of the kill ring with
416 the command @kbd{C-h v kill-ring}.
418 @node Accumulating Text, Rectangles, Yanking, Top
419 @section Accumulating Text
420 @findex append-to-buffer
421 @findex prepend-to-buffer
422 @findex copy-to-buffer
423 @findex append-to-file
425 @cindex accumulating scattered text
426 Usually we copy or move text by killing it and yanking it, but there
427 are other convenient methods for copying one block of text in many
428 places, or for copying many scattered blocks of text into one place.
429 Here we describe the commands to accumulate scattered pieces of text
430 into a buffer or into a file.
433 @item M-x append-to-buffer
434 Append region to the contents of a specified buffer.
435 @item M-x prepend-to-buffer
436 Prepend region to the contents of a specified buffer.
437 @item M-x copy-to-buffer
438 Copy region into a specified buffer, deleting that buffer's old contents.
439 @item M-x insert-buffer
440 Insert the contents of a specified buffer into current buffer at point.
441 @item M-x append-to-file
442 Append region to the contents of a specified file, at the end.
445 To accumulate text into a buffer, use @kbd{M-x append-to-buffer}.
446 This reads a buffer name, then inserts a copy of the region into the
447 buffer specified. If you specify a nonexistent buffer,
448 @code{append-to-buffer} creates the buffer. The text is inserted
449 wherever point is in that buffer. If you have been using the buffer for
450 editing, the copied text goes into the middle of the text of the buffer,
451 starting from wherever point happens to be at that moment.
453 Point in that buffer is left at the end of the copied text, so
454 successive uses of @code{append-to-buffer} accumulate the text in the
455 specified buffer in the same order as they were copied. Strictly
456 speaking, @code{append-to-buffer} does not always append to the text
457 already in the buffer---it appends only if point in that buffer is at the end.
458 However, if @code{append-to-buffer} is the only command you use to alter
459 a buffer, then point is always at the end.
461 @kbd{M-x prepend-to-buffer} is just like @code{append-to-buffer}
462 except that point in the other buffer is left before the copied text, so
463 successive prependings add text in reverse order. @kbd{M-x
464 copy-to-buffer} is similar, except that any existing text in the other
465 buffer is deleted, so the buffer is left containing just the text newly
468 The command @kbd{M-x insert-buffer} can be used to retrieve the
469 accumulated text from another buffer. This prompts for the name of a
470 buffer, and inserts a copy of all the text in that buffer into the
471 current buffer at point, leaving point at the beginning of the
472 inserted text. It also adds the position of the end of the inserted
473 text to the mark ring, without activating the mark. @xref{Buffers},
474 for background information on buffers.
476 Instead of accumulating text in a buffer, you can append text
477 directly into a file with @kbd{M-x append-to-file}. This prompts for
478 a filename, and adds the text of the region to the end of the
479 specified file. The file is changed immediately on disk.
481 You should use @code{append-to-file} only with files that are
482 @emph{not} being visited in Emacs. Using it on a file that you are
483 editing in Emacs would change the file behind Emacs's back, which
484 can lead to losing some of your editing.
486 Another way to move text around is to store it in a register.
489 @node Rectangles, CUA Bindings, Accumulating Text, Top
492 @cindex columns (and rectangles)
493 @cindex killing rectangular areas of text
495 @dfn{Rectangle} commands operate on rectangular areas of the text:
496 all the characters between a certain pair of columns, in a certain
497 range of lines. Emacs has commands to kill rectangles, yank killed
498 rectangles, clear them out, fill them with blanks or text, or delete
499 them. Rectangle commands are useful with text in multicolumn formats,
500 and for changing text into or out of such formats.
502 @cindex mark rectangle
503 When you must specify a rectangle for a command to work on, you do it
504 by putting the mark at one corner and point at the opposite corner. The
505 rectangle thus specified is called the @dfn{region-rectangle} because
506 you control it in much the same way as the region is controlled. But
507 remember that a given combination of point and mark values can be
508 interpreted either as a region or as a rectangle, depending on the
509 command that uses them.
511 If point and the mark are in the same column, the rectangle they
512 delimit is empty. If they are in the same line, the rectangle is one
513 line high. This asymmetry between lines and columns comes about
514 because point (and likewise the mark) is between two columns, but within
519 Kill the text of the region-rectangle, saving its contents as the
520 ``last killed rectangle'' (@code{kill-rectangle}).
522 Delete the text of the region-rectangle (@code{delete-rectangle}).
524 Yank the last killed rectangle with its upper left corner at point
525 (@code{yank-rectangle}).
527 Insert blank space to fill the space of the region-rectangle
528 (@code{open-rectangle}). This pushes the previous contents of the
529 region-rectangle rightward.
531 Clear the region-rectangle by replacing all of its contents with spaces
532 (@code{clear-rectangle}).
533 @item M-x delete-whitespace-rectangle
534 Delete whitespace in each of the lines on the specified rectangle,
535 starting from the left edge column of the rectangle.
536 @item C-x r t @var{string} @key{RET}
537 Replace rectangle contents with @var{string} on each line
538 (@code{string-rectangle}).
539 @item M-x string-insert-rectangle @key{RET} @var{string} @key{RET}
540 Insert @var{string} on each line of the rectangle.
543 The rectangle operations fall into two classes: commands for
544 deleting and inserting rectangles, and commands for blank rectangles.
548 @findex kill-rectangle
549 @findex delete-rectangle
550 There are two ways to get rid of the text in a rectangle: you can
551 discard the text (delete it) or save it as the ``last killed''
552 rectangle. The commands for these two ways are @kbd{C-x r d}
553 (@code{delete-rectangle}) and @kbd{C-x r k} (@code{kill-rectangle}). In
554 either case, the portion of each line that falls inside the rectangle's
555 boundaries is deleted, causing any following text on the line to
556 move left into the gap.
558 Note that ``killing'' a rectangle is not killing in the usual sense; the
559 rectangle is not stored in the kill ring, but in a special place that
560 can only record the most recent rectangle killed. This is because yanking
561 a rectangle is so different from yanking linear text that different yank
562 commands have to be used. It is hard to define yank-popping for rectangles,
566 @findex yank-rectangle
567 To yank the last killed rectangle, type @kbd{C-x r y}
568 (@code{yank-rectangle}). Yanking a rectangle is the opposite of killing
569 one. Point specifies where to put the rectangle's upper left corner.
570 The rectangle's first line is inserted there, the rectangle's second
571 line is inserted at the same horizontal position, but one line
572 vertically down, and so on. The number of lines affected is determined
573 by the height of the saved rectangle.
575 You can convert single-column lists into double-column lists using
576 rectangle killing and yanking; kill the second half of the list as a
577 rectangle and then yank it beside the first line of the list.
578 @xref{Two-Column}, for another way to edit multi-column text.
580 You can also copy rectangles into and out of registers with @kbd{C-x r
581 r @var{r}} and @kbd{C-x r i @var{r}}. @xref{RegRect,,Rectangle
585 @findex open-rectangle
587 @findex clear-rectangle
588 There are two commands you can use for making blank rectangles:
589 @kbd{C-x r c} (@code{clear-rectangle}) which blanks out existing text,
590 and @kbd{C-x r o} (@code{open-rectangle}) which inserts a blank
591 rectangle. Clearing a rectangle is equivalent to deleting it and then
592 inserting a blank rectangle of the same size.
594 @findex delete-whitespace-rectangle
595 The command @kbd{M-x delete-whitespace-rectangle} deletes horizontal
596 whitespace starting from a particular column. This applies to each of
597 the lines in the rectangle, and the column is specified by the left
598 edge of the rectangle. The right edge of the rectangle does not make
599 any difference to this command.
602 @findex string-rectangle
603 The command @kbd{C-x r t} (@code{string-rectangle}) replaces the
604 contents of a region-rectangle with a string on each line. The
605 string's width need not be the same as the width of the rectangle. If
606 the string's width is less, the text after the rectangle shifts left;
607 if the string is wider than the rectangle, the text after the
608 rectangle shifts right.
610 @findex string-insert-rectangle
611 The command @kbd{M-x string-insert-rectangle} is similar to
612 @code{string-rectangle}, but inserts the string on each line,
613 shifting the original text to the right.
615 @node CUA Bindings, Registers, Rectangles, Top
616 @section CUA Bindings
619 @cindex CUA key bindings
620 @vindex cua-enable-cua-keys
621 The command @kbd{M-x cua-mode} sets up key bindings that are
622 compatible with the Common User Access (CUA) system used in many other
623 applications. @kbd{C-x} means cut (kill), @kbd{C-c} copy, @kbd{C-v}
624 paste (yank), and @kbd{C-z} undo. Standard Emacs commands like
625 @kbd{C-x C-c} still work, because @kbd{C-x} and @kbd{C-c} only take
626 effect when the mark is active (and the region is highlighted).
627 However, if you don't want to override these bindings in Emacs at all,
628 set @code{cua-enable-cua-keys} to @code{nil}.
630 To enter an Emacs command like @kbd{C-x C-f} while the mark is
631 active, use one of the following methods: either hold @kbd{Shift}
632 together with the prefix key, e.g. @kbd{S-C-x C-f}, or quickly type
633 the prefix key twice, e.g. @kbd{C-x C-x C-f}.
635 In CUA mode, typed text replaces the active region as in
636 Delete-Selection mode (@pxref{Mouse Commands}).
638 @cindex rectangle highlighting
639 CUA mode provides enhanced rectangle support with visible
640 rectangle highlighting. Use @kbd{C-RET} to start a rectangle,
641 extend it using the movement commands, and cut or copy it using
642 @kbd{C-x} or @kbd{C-c}. @kbd{RET} moves the cursor to the next
643 (clockwise) corner of the rectangle, so you can easily expand it in
644 any direction. Normal text you type is inserted to the left or right
645 of each line in the rectangle (on the same side as the cursor).
647 With CUA you can easily copy text and rectangles into and out of
648 registers by providing a one-digit numeric prefix to the kill, copy,
649 and yank commands, e.g. @kbd{C-1 C-c} copies the region into register
650 @code{1}, and @kbd{C-2 C-v} yanks the contents of register @code{2}.
653 CUA mode also has a global mark feature which allows easy moving and
654 copying of text between buffers. Use @kbd{C-S-SPC} to toggle the
655 global mark on and off. When the global mark is on, all text that you
656 kill or copy is automatically inserted at the global mark, and text
657 you type is inserted at the global mark rather than at the current
660 For example, to copy words from various buffers into a word list in
661 a given buffer, set the global mark in the target buffer, then
662 navigate to each of the words you want in the list, mark it (e.g. with
663 @kbd{S-M-f}), copy it to the list with @kbd{C-c} or @kbd{M-w}, and
664 insert a newline after the word in the target list by pressing
672 arch-tag: d8da8f96-0928-449a-816e-ff2d3497866c