428
+ − 1 @comment node-name, next, previous, up
+ − 2 @node Edit, Customization Basics, Windows and Menus, Top
+ − 3 @chapter Basic Editing Commands
+ − 4
+ − 5 @kindex C-h t
+ − 6 @findex help-with-tutorial
+ − 7 This chapter will introduce you to some basic editing commands. You
+ − 8 can also learn the basic editing commands by typing @kbd{Control-h t}
+ − 9 (@code{help-with-tutorial} OR by selecting @b{Emacs Tutorial} from the
+ − 10 @b{Help} menu on the menu bar. Most of the Emacs commands will use the
+ − 11 @key{CONTROL} key or the @key{META} key. The following abbreviations
+ − 12 will be used for the @key{CONTROL} and @key{META} key in this manual:
+ − 13
+ − 14 @table @kbd
+ − 15 @item C-<chr>
+ − 16 This means that you should hold down the @key{CONTROL} key while typing
+ − 17 @kbd{<chr>}. For example, if the command is @kbd{C-g}, you should hold
+ − 18 the @key{CONTROL} key and type @key{g}.
+ − 19 @item M-<chr>
+ − 20 This means that you should hold down the @kbd{META} key while typing
+ − 21 @kbd{<chr>}. If there is no @kbd{META} key on your keyboard, use the
+ − 22 @kbd{ESC} key instead. For example, if the command is @kbd{M-x}, then
+ − 23 type @kbd{ESC}, release it and type @kbd{x}.
+ − 24 @end table
+ − 25
+ − 26 The following abbreviations will be used for some other keys:
+ − 27
+ − 28 @table @key
+ − 29 @item SPC
+ − 30 Space bar.
+ − 31 @item RET
+ − 32 Return key.
+ − 33 @item LFD
+ − 34 Linefeed key.
+ − 35 @item TAB
+ − 36 Tab.
+ − 37 @item ESC
+ − 38 Escape.
+ − 39 @item SFT
+ − 40 Shift.
+ − 41 @end table
+ − 42
+ − 43 @comment node-name, next, previous, up
+ − 44 @menu
+ − 45 * Insert:: Insert text in Emacs by simply typing at
+ − 46 the cursor position.
+ − 47 * Cursor Position:: Moving Around the cursor in the buffer,
+ − 48 * Erase:: Different commands for erasing text
+ − 49 * Numeric Argument:: Giving Numeric Arguments to commands
+ − 50 * Undo:: Undoing Changes made by mistake
+ − 51 @end menu
+ − 52
+ − 53 @node Insert, Cursor Position, Edit, Edit
+ − 54 @section Inserting Text
+ − 55
+ − 56 @cindex insertion
+ − 57 @cindex overstrike
+ − 58 To insert printing characters into the text you are editing, just
+ − 59 type them. Emacs will automatically insert the characters that you type
+ − 60 into the buffer at the cursor. The cursor moves forward, but if you
+ − 61 prefer to have text characters replace (overwrite) existing text
+ − 62 characters, you can enable the @b{Overstrike} option from the
+ − 63 @b{Options} menu in the menu bar.
+ − 64
+ − 65 @kindex DEL
+ − 66 @cindex deletion
+ − 67 To @dfn{delete} text you have just inserted, use @key{DEL}.
+ − 68 @key{DEL} deletes the character @var{before} the cursor (not the one
+ − 69 that the cursor is on top of or under; that is the character @var{after}
+ − 70 the cursor). The cursor and all characters after it move backwards.
+ − 71 Therefore, if you type a printing character and then type @key{DEL},
+ − 72 they cancel out.
+ − 73
+ − 74 @kindex RET
+ − 75 @cindex newline
+ − 76 @findex auto-fill-mode
+ − 77 To end a line and start typing a new one, type @key{RET}. This
+ − 78 inserts a newline character in the buffer. If point is in the middle of
+ − 79 a line, @key{RET} splits the line. Typing @key{DEL} when the cursor is
+ − 80 at the beginning of a line rubs out the newline before the line, thus
+ − 81 joining the line with the preceding line.
+ − 82
+ − 83 Emacs automatically splits lines when they become too long, if you
+ − 84 turn on a special mode called @dfn{Auto Fill} mode.
+ − 85 @xref{Filling,,,xemacs,XEmacs User's Manual}, for information on using Auto Fill
+ − 86 mode.
+ − 87
+ − 88
+ − 89 @comment node-name, next, previous, up
+ − 90 @node Cursor Position, Erase, Insert, Edit
+ − 91 @section Moving Around
+ − 92 @cindex cursor control
+ − 93 @cindex cursor position
+ − 94
+ − 95 The following commands will allow you to move the cursor around the
+ − 96 screen. The actual function names corresponding to these commands are
+ − 97 given in parenthesis. You can also invoke these commands by typing
+ − 98 @kbd{M-x <function name>}. You can do this for any command in XEmacs.
+ − 99
+ − 100 @kindex C-a
+ − 101 @kindex C-e
+ − 102 @kindex C-fx
+ − 103 @kindex C-b
+ − 104 @kindex C-n
+ − 105 @kindex C-p
+ − 106 @kindex C-v
+ − 107 @kindex M-v
+ − 108 @kindex C-t
+ − 109 @kindex M->
+ − 110 @kindex M-<
+ − 111 @findex beginning-of-line
+ − 112 @findex end-of-line
+ − 113 @findex forward-char
+ − 114 @findex backward-char
+ − 115 @findex next-line
+ − 116 @findex previous-line
+ − 117 @findex transpose-chars
+ − 118 @findex beginning-of-buffer
+ − 119 @findex end-of-buffer
+ − 120 @findex goto-char
+ − 121 @findex goto-line
+ − 122 @table @kbd
+ − 123 @item C-b
+ − 124 Move the cursor backward one character (@code{backward-char}).
+ − 125 @item C-f
+ − 126 Move the cursor forward one character (@code{forward-char}).
+ − 127 @item C-p
+ − 128 Move the cursor up one line vertically (@code{previous-line}).
+ − 129 @item C-n
+ − 130 Move the cursor down one line vertically (@code{next-line}).
+ − 131 @item C-a
+ − 132 Move the cursor to the beginning of the line (@code{beginning-of-line}).
+ − 133 @item C-e
+ − 134 Move the cursor to the end of the line (@code{end-of-line}).
+ − 135 @item M-f
+ − 136 @findex forward-word
+ − 137 Move the cursor forward one word (@code{forward-word}).
+ − 138 @item M-b
+ − 139 @findex backward-word
442
+ − 140 Move the cursor backward one word (@code{backward-word}).
428
+ − 141 @item M-<
+ − 142 Move the cursor to the top of the buffer (@code{beginning-of-buffer}).
+ − 143 @item M->
+ − 144 Move the cursor to the end of the buffer (@code{end-of-buffer}).
+ − 145 @item M-x goto-char RET <number> RET
+ − 146 To enable this command type @kbd{M-x goto-char}, and hit @key{RETURN}
+ − 147 key. In the @dfn{echo area} you will see:
+ − 148
+ − 149 @example
+ − 150 Goto char:
+ − 151 @end example
+ − 152
+ − 153 @noindent
+ − 154 You should then type in a number right after the colon
+ − 155 and hit the @kbd{RETURN} key again. After reading a number @var{n} this
+ − 156 command will move the cursor to character number @var{n}.
+ − 157 Position 1 is the beginning of the buffer. For example, if you type
+ − 158 @kbd{M-x goto-char RET 200 RET}, then the cursor will move to the 200th
+ − 159 character starting from the beginning of the buffer.
+ − 160
+ − 161 @item M-x goto-line RET <number> RET
+ − 162 @cindex goto-line
+ − 163 To enable this command type @kbd{M-x goto-line}, and hit the
+ − 164 @key{RETURN} key. After you see @kbd{Goto line:} in the @dfn{echo area},
+ − 165 type in a number @var{n} and hit @key{RETURN} key again. This command will
+ − 166 position the cursor on the nth line starting from the beginning of the
+ − 167 buffer.
+ − 168 @item M-x what-line RET
+ − 169 This command will display the current line number in the echo area.
+ − 170
+ − 171 @end table
+ − 172
+ − 173
+ − 174 @comment node-name, next, previous, up
+ − 175 @node Erase, Numeric Argument, Cursor Position, Edit
+ − 176 @section Erasing Text
+ − 177
+ − 178 @cindex erasing
+ − 179 @cindex deleting
+ − 180 @kindex C-d
+ − 181 @kindex C-k
+ − 182 @kindex M-d
+ − 183 @kindex M-DEL
+ − 184 @kindex M-k
+ − 185 @kindex M-z
+ − 186 @findex delete-backward-char
+ − 187 @findex delete-char
+ − 188 @findex kill-line
+ − 189 @findex kill-word
+ − 190 @findex backward-kill-word
+ − 191 @findex kill-sentence
+ − 192 @findex zap-to-char
+ − 193
+ − 194 @table @kbd
+ − 195 @item @key{DEL}
+ − 196 If you press @key{DEL} i.e. the @dfn{delete} key, it will delete the
+ − 197 character before the cursor (@code{delete-backward-char}).
+ − 198 @item C-d
+ − 199 This will delete the character after the cursor (@code{delete-char}).
+ − 200 @item C-k
+ − 201 Kill to the end of the line (@code{kill-line}). If you kill the line by
+ − 202 mistake you can @dfn{yank} or @samp{paste} it back by typing
+ − 203 @kbd{C-y}. @xref{Moving Text}, for more information on yanking.
+ − 204 @item M-d
+ − 205 Kill forward to the end of the next word (@code{kill-word}).
+ − 206 @item M-@key{DEL}
+ − 207 Kill back to the beginning of the previous word
+ − 208 (@code{backward-kill-word}).
+ − 209 @item M-k
+ − 210 Kill to the end of current sentence (@code{kill-sentence}).
+ − 211 @item M-z @var{char}
+ − 212 Kill up to next occurrence of @var{char} (@code{zap-to-char}). To use
+ − 213 this command type @kbd{M-z}. You will see the following statement in the
+ − 214 echo area :
+ − 215
+ − 216 @example
+ − 217 Zap to char:
+ − 218 @end example
+ − 219
+ − 220 Type any char and press the @key{RET} key. For example, if you type
+ − 221 @samp{p} then the entire text starting from the position of the cursor
+ − 222 until the first occurrence of @samp{p} is killed.
+ − 223 @end table
+ − 224
+ − 225
+ − 226 @comment node-name, next, previous, up
+ − 227 @node Numeric Argument, Undo, Erase, Edit
+ − 228 @section Giving Numeric Arguments
+ − 229 @cindex numeric argument
+ − 230 @cindex digit argument
+ − 231 @cindex negative argument
+ − 232 @kindex C-u
+ − 233 @kindex M-@t{-}
+ − 234
+ − 235 Any Emacs command can be given a @dfn{numeric argument}. Some commands
+ − 236 interpret the argument as a repetition count. For example, if you want
+ − 237 to move forward ten characters, you could type @kbd{C-f} ten
+ − 238 times. However, a more efficient way to do this would be to give an
+ − 239 argument of ten to the key @kbd{C-f} (the command @code{forward-char}, move
+ − 240 forward one character). Negative arguments are also allowed. Often they tell
+ − 241 a command to move or act backwards. For example, if you want to move
+ − 242 down ten lines, type the following:
+ − 243 @example
+ − 244 C-u 10 C-n RET
+ − 245 @end example
+ − 246 @noindent
+ − 247 After you press @key{RET} key, the cursor will move ten lines
+ − 248 downward. You can also type:
+ − 249 @example
+ − 250 M-10 C-n RET
+ − 251 @end example
+ − 252 @noindent
+ − 253 Both @kbd{C-u} and @kbd{M-} allow you to give numeric arguments. If you
+ − 254 want to move ten lines backward, you can also give negative arguments, like:
+ − 255 @example
+ − 256 C-u -10 C-n RET
+ − 257 @end example
+ − 258 @noindent
+ − 259 OR you could also type:
+ − 260 @example
+ − 261 M--10 C-n RET
+ − 262 @end example
+ − 263 @noindent
+ − 264 You can obviously use @kbd{C-b} to move backward rather than giving
+ − 265 negative arguments to @kbd{C-n}. @xref{Numeric Arguments,,,xemacs,XEmacs
+ − 266 User's Manual}, for more information on numeric arguments.
+ − 267
+ − 268 @comment node-name, next, previous, up
+ − 269 @node Undo, , Numeric Argument, Edit
+ − 270 @section Undoing Changes
+ − 271 @cindex undo
+ − 272 @cindex mistakes, correcting
+ − 273
+ − 274 When you are editing a buffer, you might type something by
+ − 275 mistake. Emacs allows you to undo all changes you make to a buffer (but
+ − 276 not more than 8000 characters). Each buffer in Emacs keeps a record of
+ − 277 the changes made to it individually, so the undo command applies to the
+ − 278 current buffer. There are two undo commands:
+ − 279
+ − 280 @table @kbd
+ − 281 @kindex C-x u
+ − 282 @item C-x u
+ − 283 Undo one batch of changes (usually, one command's worth).
+ − 284 (@code{undo}).
+ − 285 @item C-_
+ − 286 The same as above, but this command might not be obvious to type on some
+ − 287 keyboards so it might be better to use the above command.
+ − 288 @end table
+ − 289
+ − 290 @xref{Undoing Changes,,,xemacs,XEmacs User's Manual}, for more information on
+ − 291 undoing changes.
+ − 292
+ − 293
+ − 294
+ − 295
+ − 296
+ − 297
+ − 298
+ − 299
+ − 300
+ − 301