XEmacs 21.4.20 "Double Solitaire".
[chise/xemacs-chise.git.1] / man / new-users-guide / edit.texi
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   Unfortunately, computer and keyboard manufacturers differ over the
75 name of the @key{DEL} key.  This is the key at the far right of the row
76 of keys containing the digits, usually immediately above the @kbd{RET}
77 key.  It is usually labelled ``Backspace'' or ``Delete'' or some
78 abbreviation.  Modern keyboards will often have another key labelled
79 ``Del'' in the @emph{edit keypad} (along with an ``Ins'' key and perhaps
80 some others).  This is not the @kbd{DEL} key referred to here.  It
81 usually deletes @emph{forward} in Emacs.
82
83 @kindex RET
84 @cindex newline
85 @findex auto-fill-mode
86    To end a line and start typing a new one, type @key{RET}.  On some
87 keyboards, this key is labelled ``Enter''.  This
88 inserts a newline character in the buffer.  If point is in the middle of
89 a line, @key{RET} splits the line.  Typing @key{DEL} when the cursor is
90 at the beginning of a line rubs out the newline before the line, thus
91 joining the line with the preceding line.
92
93   Emacs automatically splits lines when they become too long, if you
94 turn on a special mode called @dfn{Auto Fill} mode.
95 @xref{Filling,,,xemacs,XEmacs User's Manual}, for information on using Auto Fill
96 mode.
97
98
99 @comment  node-name,  next,  previous,  up
100 @node Cursor Position, Erase, Insert, Edit
101 @section Moving Around
102 @cindex cursor control
103 @cindex cursor position
104
105   The following commands will allow you to move the cursor around the
106 screen. The actual function names corresponding to these commands are
107 given in parenthesis. You can also invoke these commands by typing
108 @kbd{M-x <function name>}. You can do this for any command in XEmacs.
109
110 @kindex C-a
111 @kindex C-e
112 @kindex C-fx
113 @kindex C-b
114 @kindex C-n
115 @kindex C-p
116 @kindex C-v
117 @kindex M-v
118 @kindex C-t
119 @kindex M->
120 @kindex M-<
121 @findex beginning-of-line
122 @findex end-of-line
123 @findex forward-char
124 @findex backward-char
125 @findex next-line
126 @findex previous-line
127 @findex transpose-chars
128 @findex beginning-of-buffer
129 @findex end-of-buffer
130 @findex goto-char
131 @findex goto-line
132 @table @kbd
133 @item C-b
134 Move the cursor backward one character (@code{backward-char}). 
135 @item C-f
136 Move the cursor forward one character (@code{forward-char}).
137 @item C-p
138 Move the cursor up one line vertically (@code{previous-line}).
139 @item C-n
140 Move the cursor down one line vertically (@code{next-line}).
141 @item C-a
142 Move the cursor to the beginning of the line (@code{beginning-of-line}).
143 @item C-e
144 Move the cursor to the end of the line (@code{end-of-line}).
145 @item M-f
146 @findex forward-word
147 Move the cursor forward one word (@code{forward-word}).
148 @item M-b
149 @findex backward-word
150 Move the cursor backward one word (@code{backward-word}).
151 @item M-<
152 Move the cursor to the top of the buffer (@code{beginning-of-buffer}).
153 @item M->
154 Move the cursor to the end of the buffer (@code{end-of-buffer}).
155 @item M-x goto-char RET <number> RET
156 To enable this command type @kbd{M-x goto-char}, and hit @key{RETURN}
157 key. In the @dfn{echo area} you will see:
158
159 @example
160 Goto char:
161 @end example
162
163 @noindent
164 You should then type in a number right after the colon 
165 and hit the @kbd{RETURN} key again. After reading a number @var{n} this
166 command will move the cursor to character number @var{n}.
167 Position 1 is the beginning of the buffer. For example, if you type
168 @kbd{M-x goto-char RET 200 RET}, then the cursor will move to the 200th
169 character starting from the beginning of the buffer.
170
171 @item M-x goto-line RET <number> RET
172 @cindex goto-line
173 To enable this command type @kbd{M-x goto-line}, and hit the
174 @key{RETURN} key. After you see @kbd{Goto line:} in the @dfn{echo area},
175 type in a number @var{n} and hit @key{RETURN} key again. This command will
176 position the cursor on the nth line starting from the beginning of the
177 buffer.
178 @item M-x what-line RET
179 This command will display the current line number in the echo area.
180
181 @end table
182
183
184 @comment  node-name,  next,  previous,  up
185 @node Erase, Numeric Argument, Cursor Position, Edit
186 @section Erasing Text
187
188 @cindex erasing
189 @cindex deleting
190 @kindex C-d
191 @kindex C-k
192 @kindex M-d
193 @kindex M-DEL
194 @kindex M-k
195 @kindex M-z
196 @findex delete-backward-char
197 @findex delete-char
198 @findex kill-line
199 @findex kill-word
200 @findex backward-kill-word
201 @findex kill-sentence
202 @findex zap-to-char
203
204 @table @kbd
205 @item @key{DEL}
206 If you press @key{DEL} i.e. the @dfn{delete} key, it will delete the 
207 character before the cursor (@code{delete-backward-char}).
208 @item C-d
209 This will delete the character after the cursor (@code{delete-char}).
210 @item C-k
211 Kill to the end of the line (@code{kill-line}). If you kill the line by
212 mistake you can @dfn{yank} or @samp{paste} it back by typing
213 @kbd{C-y}. @xref{Moving Text}, for more information on yanking.
214 @item M-d
215 Kill forward to the end of the next word (@code{kill-word}).
216 @item M-@key{DEL}
217 Kill back to the beginning of the previous word
218 (@code{backward-kill-word}).
219 @item M-k
220 Kill to the end of current sentence (@code{kill-sentence}).
221 @item M-z @var{char}
222 Kill up to next occurrence of @var{char} (@code{zap-to-char}). To use
223 this command type @kbd{M-z}. You will see the following statement in the
224 echo area :
225
226 @example
227 Zap to char:
228 @end example
229
230 Type any char and press the @key{RET} key. For example, if you type
231 @samp{p} then the entire text starting from the position of the cursor
232 until the first occurrence of @samp{p} is killed. 
233 @end table
234
235
236 @comment  node-name,  next,  previous,  up
237 @node Numeric Argument, Undo, Erase, Edit
238 @section Giving Numeric Arguments
239 @cindex numeric argument
240 @cindex digit argument
241 @cindex negative argument
242 @kindex C-u
243 @kindex M-@t{-}
244
245   Any Emacs command can be given a @dfn{numeric argument}.  Some commands
246 interpret the argument as a repetition count.  For example, if you want
247 to move forward ten characters, you could type @kbd{C-f} ten
248 times. However, a more efficient way to do this would be to give an
249 argument of ten to the key @kbd{C-f} (the command @code{forward-char}, move
250 forward one character). Negative arguments are also allowed. Often they tell
251 a command to move or act backwards. For example, if you want to move
252 down ten lines, type the following:
253 @example
254 C-u 10 C-n
255 @end example
256 @noindent
257 After you press the @kbd{C-n} key, the cursor will move ten lines
258 downward. You can also type:
259 @example
260 M-10 C-n
261 @end example
262 @noindent
263 Both @kbd{C-u} and @kbd{M-} allow you to give numeric arguments. If you
264 want to move ten lines backward, you can also give negative arguments, like:
265 @example
266 C-u -10 C-n
267 @end example
268 @noindent
269 OR you could also type:
270 @example
271 M--10 C-n
272 @end example
273 @noindent
274 You can obviously use @kbd{C-b} to move backward rather than giving
275 negative arguments to @kbd{C-n}. @xref{Numeric Arguments,,,xemacs,XEmacs
276 User's Manual}, for more information on numeric arguments.
277
278 @comment  node-name,  next,  previous,  up
279 @node Undo,  , Numeric Argument, Edit
280 @section Undoing Changes
281 @cindex undo
282 @cindex mistakes, correcting
283
284   When you are editing a buffer, you might type something by
285 mistake. Emacs allows you to undo all changes you make to a buffer (but
286 not more than 8000 characters). Each buffer in Emacs keeps a record of
287 the changes made to it individually, so the undo command applies to the
288 current buffer. There are two undo commands:
289
290 @table @kbd
291 @kindex C-x u
292 @item C-x u
293 Undo one batch of changes (usually, one command's worth).
294 (@code{undo}). 
295 @item C-_
296 The same as above, but this command might not be obvious to type on some
297 keyboards so it might be better to use the above command.
298 @end table
299
300   @xref{Undoing Changes,,,xemacs,XEmacs User's Manual}, for more information on
301 undoing changes.
302   
303   
304
305
306
307
308
309
310
311