comparison man/killing.texi @ 36162:f657bb5a6cf5

Rewrite kill-read-only-ok, Delete Selection mode, replace-rectangle.
author Richard M. Stallman <rms@gnu.org>
date Sat, 17 Feb 2001 17:35:47 +0000
parents 89bf4e8936b6
children 0ee33338bb24
comparison
equal deleted inserted replaced
36161:f6ba7a00b9e1 36162:f657bb5a6cf5
1 @c This is part of the Emacs manual. 1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985,86,87,93,94,95,97,2000 Free Software Foundation, Inc. 2 @c Copyright (C) 1985,86,87,93,94,95,97,00,2001 Free Software Foundation, Inc.
3 @c See file emacs.texi for copying conditions. 3 @c See file emacs.texi for copying conditions.
4 @iftex 4 @iftex
5 @chapter Killing and Moving Text 5 @chapter Killing and Moving Text
6 6
7 @dfn{Killing} means erasing text and copying it into the @dfn{kill 7 @dfn{Killing} means erasing text and copying it into the @dfn{kill
35 can use the @kbd{C-x u} (@code{undo}) command to undo it 35 can use the @kbd{C-x u} (@code{undo}) command to undo it
36 (@pxref{Undo}). 36 (@pxref{Undo}).
37 37
38 @vindex kill-read-only-ok 38 @vindex kill-read-only-ok
39 @cindex read-only text, killing 39 @cindex read-only text, killing
40 By default, Emacs does not allow to kill text in read-only buffers. 40 You cannot kill read-only text, since such text does not allow any
41 Setting the variable @code{kill-read-only-ok} to a non-@code{nil} value 41 kind of modification. But some users like to use the kill commands to
42 overrides that. To alert you to the fact that you killed read-only 42 copy read-only text into the kill ring, without actually changing it.
43 text, Emacs prints a message to that effect in the echo area. 43 If you set the variable @code{kill-read-only-ok} to a non-@code{nil}
44 44 value, the kill commands work specially in a read-only buffer: they
45 When @code{kill-read-only-ok} is @code{nil}, Emacs beeps if you try to 45 move over text, and copy it to the kill ring, without actually
46 kill text in a read-only buffers, but it puts the text you wanted to 46 deleting it from the buffer. When this happens, a message in the echo
47 kill into the kill ring anyway. This means you can use kill commands to 47 area tells you what is happening.
48 copy text from read-only buffers.
49 48
50 The delete commands include @kbd{C-d} (@code{delete-char}) and 49 The delete commands include @kbd{C-d} (@code{delete-char}) and
51 @key{DEL} (@code{delete-backward-char}), which delete only one character at 50 @key{DEL} (@code{delete-backward-char}), which delete only one character at
52 a time, and those commands that delete only spaces or newlines. Commands 51 a time, and those commands that delete only spaces or newlines. Commands
53 that can destroy significant amounts of nontrivial data generally kill. 52 that can destroy significant amounts of nontrivial data generally kill.
55 and @samp{delete} to say which they do. 54 and @samp{delete} to say which they do.
56 55
57 @cindex Delete Selection mode 56 @cindex Delete Selection mode
58 @cindex mode, Delete Selection 57 @cindex mode, Delete Selection
59 @findex delete-selection-mode 58 @findex delete-selection-mode
60 You can arrange for selected text to be killed when you insert something 59 Many window systems follow the convention that insertion while text
61 and replaced by what you insert; this is the way many text interfaces 60 is selected deletes the selected text. You can make Emacs behave this
62 work. To do this turn on Delete Selection mode. with @kbd{M-x 61 way by enabling Delete Selection mode, with @kbd{M-x
63 delete-selection-mode} or using Custom. Also in Delete Selection mode 62 delete-selection-mode}, or using Custom. Another effect of this mode
64 @key{DEL}, @kbd{C-d} and some other keys will just kill the whole 63 is that @key{DEL}, @kbd{C-d} and some other keys, when a selection
65 selection and Transient Mark mode is turned on (@pxref{Transient Mark}). 64 exists, will kill the whole selection. It also enables Transient Mark
65 mode (@pxref{Transient Mark}).
66 66
67 @menu 67 @menu
68 * Deletion:: Commands for deleting small amounts of text and 68 * Deletion:: Commands for deleting small amounts of text and
69 blank areas. 69 blank areas.
70 * Killing by Lines:: How to kill entire lines of text at one time. 70 * Killing by Lines:: How to kill entire lines of text at one time.
500 Delete whitespace in each of the lines on the specified rectangle, 500 Delete whitespace in each of the lines on the specified rectangle,
501 starting from the left edge column of the rectangle. 501 starting from the left edge column of the rectangle.
502 @item C-x r t @var{string} @key{RET} 502 @item C-x r t @var{string} @key{RET}
503 Insert @var{string} on each line of the region-rectangle 503 Insert @var{string} on each line of the region-rectangle
504 (@code{string-rectangle}). 504 (@code{string-rectangle}).
505 @item M-x replace-rectangle @key{RET} @var{string} @key{RET}
506 Replaces each line of the region-rectangle with @var{string}
507 (@code{string-rectangle}).
505 @end table 508 @end table
506 509
507 The rectangle operations fall into two classes: commands deleting and 510 The rectangle operations fall into two classes: commands deleting and
508 inserting rectangles, and commands for blank rectangles. 511 inserting rectangles, and commands for blank rectangles.
509 512
560 edge of the rectangle. The right edge of the rectangle does not make 563 edge of the rectangle. The right edge of the rectangle does not make
561 any difference to this command. 564 any difference to this command.
562 565
563 @kindex C-x r t 566 @kindex C-x r t
564 @findex string-rectangle 567 @findex string-rectangle
565 The command @kbd{C-x r t} (@code{M-x string-rectangle}) inserts a 568 The command @kbd{C-x r t} (@code{M-x string-rectangle}) inserts a
566 string on each line of the region-rectangle before the rectangle, 569 string on each line of the region-rectangle before the rectangle,
567 shifting text right. 570 shifting text right.
568 571
569 @findex replace-rectangle 572 @findex replace-rectangle
570 The command @kbd{M-x replace-rectangle} is similar, but replaces the 573 The command @kbd{M-x replace-rectangle} is similar to @kbd{C-x r t},
571 original rectangle. The string's width need not be the same as the 574 but replaces the original rectangle. The string's width need not be
572 width of the rectangle. If the string's width is less, the text after 575 the same as the width of the rectangle. If the string's width is
573 the rectangle shifts left; if the string is wider than the rectangle, 576 less, the text after the rectangle shifts left; if the string is wider
574 the text after the rectangle shifts right. 577 than the rectangle, the text after the rectangle shifts right.