1 @comment node-name, next, previous, up
2 @node Edit, Customization Basics, Windows and Menus, Top
3 @chapter Basic Editing Commands
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:
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}.
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}.
26 The following abbreviations will be used for some other keys:
43 @comment node-name, next, previous, up
45 * Insert:: Insert text in Emacs by simply typing at
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
53 @node Insert, Cursor Position, Edit, Edit
54 @section Inserting Text
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.
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},
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.
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
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
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.
111 @findex beginning-of-line
114 @findex backward-char
116 @findex previous-line
117 @findex transpose-chars
118 @findex beginning-of-buffer
119 @findex end-of-buffer
124 Move the cursor backward one character (@code{backward-char}).
126 Move the cursor forward one character (@code{forward-char}).
128 Move the cursor up one line vertically (@code{previous-line}).
130 Move the cursor down one line vertically (@code{next-line}).
132 Move the cursor to the beginning of the line (@code{beginning-of-line}).
134 Move the cursor to the end of the line (@code{end-of-line}).
137 Move the cursor forward one word (@code{forward-word}).
139 @findex backward-word
140 Move the cursor backward one word (@code{backward-word}).
142 Move the cursor to the top of the buffer (@code{beginning-of-buffer}).
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:
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.
161 @item M-x goto-line RET <number> RET
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
168 @item M-x what-line RET
169 This command will display the current line number in the echo area.
174 @comment node-name, next, previous, up
175 @node Erase, Numeric Argument, Cursor Position, Edit
176 @section Erasing Text
186 @findex delete-backward-char
190 @findex backward-kill-word
191 @findex kill-sentence
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}).
199 This will delete the character after the cursor (@code{delete-char}).
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.
205 Kill forward to the end of the next word (@code{kill-word}).
207 Kill back to the beginning of the previous word
208 (@code{backward-kill-word}).
210 Kill to the end of current sentence (@code{kill-sentence}).
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
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.
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
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:
247 After you press @key{RET} key, the cursor will move ten lines
248 downward. You can also type:
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:
259 OR you could also type:
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.
268 @comment node-name, next, previous, up
269 @node Undo, , Numeric Argument, Edit
270 @section Undoing Changes
272 @cindex mistakes, correcting
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:
283 Undo one batch of changes (usually, one command's worth).
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.
290 @xref{Undoing Changes,,,xemacs,XEmacs User's Manual}, for more information on