summaryrefslogtreecommitdiff
path: root/misc/slackbook/html/emacs-basic-editing.html
blob: fbc5072b436eb57d9ea2e782c4c500669ec58470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>Basic Editing</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
<link rel="UP" title="Emacs" href="emacs.html" />
<link rel="PREVIOUS" title="Modes" href="emacs-modes.html" />
<link rel="NEXT" title="Saving Files" href="emacs-saving-files.html" />
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th colspan="3" align="center">Slackware Linux Essentials</th>
</tr>

<tr>
<td width="10%" align="left" valign="bottom"><a href="emacs-modes.html"
accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom">Chapter 17 Emacs</td>
<td width="10%" align="right" valign="bottom"><a href="emacs-saving-files.html"
accesskey="N">Next</a></td>
</tr>
</table>

<hr align="LEFT" width="100%" />
</div>

<div class="SECT1">
<h1 class="SECT1"><a id="EMACS-BASIC-EDITING" name="EMACS-BASIC-EDITING">17.4 Basic
Editing</a></h1>

<p>When you have opened a file, you can of course move around in it with the cursor. The
<b class="KEYCAP">cursor keys</b> and <b class="KEYCAP">PgUp</b>, <b
class="KEYCAP">PgDn</b> do what you'd expect. <b class="KEYCAP">Home</b> and <b
class="KEYCAP">End</b> jump to the beginning and end of the line. (In older versions,
they would actually jump to the beginning and end of the buffer.) However, there are also
<b class="KEYCAP">Control</b> and <b class="KEYCAP">Meta</b> (<b class="KEYCAP">Alt</b>)
key combos that move the cursor around. Because you do not need to move your hands to
another part of the keyboard for these, they are much quicker once you get used to them.
The most important such commands are listed in <a
href="emacs-basic-editing.html#TABLE-EMACS-BASIC-EDITING">Table 17-1</a>.</p>

<div class="TABLE"><a id="TABLE-EMACS-BASIC-EDITING"
name="TABLE-EMACS-BASIC-EDITING"></a>
<p><b>Table 17-1. Basic Emacs Editing Commands</b></p>

<table border="0" frame="void" width="100%" class="CALSTABLE">
<col width="25%" />
<col width="75%" />
<thead>
<tr>
<th>Command</th>
<th>Result</th>
</tr>
</thead>

<tbody>
<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">b</b> </td>
<td>go one character back</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">f</b> </td>
<td>go one character forward</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">n</b> </td>
<td>go one line down</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">p</b> </td>
<td>go one line up</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">a</b> </td>
<td>go to the beginning of the line</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">e</b> </td>
<td>go to the end of the line</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">b</b> </td>
<td>go one word back</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">f</b> </td>
<td>go one word forward</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">}</b> </td>
<td>go one paragraph forward</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">{</b> </td>
<td>go one paragraph backward</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">a</b> </td>
<td>go one sentence backward</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">e</b> </td>
<td>go one sentence forward</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">d</b> </td>
<td>delete the character under the cursor</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">d</b> </td>
<td>delete until the end of the current word</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">v</b> </td>
<td>go down one screen (i.e., PgDn)</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">v</b> </td>
<td>go up one screen (i.e., PgUp)</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">&lt;</b> </td>
<td>go to the beginning of the buffer</td>
</tr>

<tr>
<td><b class="KEYCAP">M</b>-<b class="KEYCAP">&gt;</b> </td>
<td>go to the end of the buffer</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">_</b> </td>
<td>undo the last change (can be repeated); note that you actually have to type <b
class="KEYCAP">Shift</b>+<b class="KEYCAP">Control</b>+<b class="KEYCAP">hyphen</b> for
this.</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">k</b> </td>
<td>delete to end of line</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">s</b> </td>
<td>forward search</td>
</tr>

<tr>
<td><b class="KEYCAP">C</b>-<b class="KEYCAP">r</b> </td>
<td>backward search</td>
</tr>
</tbody>
</table>
</div>

<p>Note that many <b class="KEYCAP">Meta</b> commands are parallel to the <b
class="KEYCAP">Control</b> commands except that they operate on larger units: while <b
class="KEYCAP">C</b>-<b class="KEYCAP">f</b> goes forward one character, <b
class="KEYCAP">M</b>-<b class="KEYCAP">f</b> goes forward an entire word, etc.</p>

<p>Also note that <b class="KEYCAP">M</b>-<b class="KEYCAP">&lt;</b> and <b
class="KEYCAP">M</b>-<b class="KEYCAP">&gt;</b> require you to type <b
class="KEYCAP">Shift</b>+<b class="KEYCAP">Alt</b>+<b class="KEYCAP">comma</b> and <b
class="KEYCAP">Shift</b>+<b class="KEYCAP">Alt</b>+<b class="KEYCAP">dot</b>
respectively, since <b class="KEYCAP">&lt;</b> and <b class="KEYCAP">&gt;</b> are on <b
class="KEYCAP">Shift</b>+<b class="KEYCAP">comma</b> and <b class="KEYCAP">Shift</b>+<b
class="KEYCAP">dot</b>. (Unless of course you have a different keyboard layout from the
standard US layout.)</p>

<p>Note that <b class="KEYCAP">C</b>-<b class="KEYCAP">k</b> deletes (kills, as it is
commonly called) all the text after the cursor to the end of the line, but doesn't delete
the line itself (i.e., it doesn't delete the final newline). It only deletes the line if
there was no text after the cursor. In other words, in order to delete a complete line,
you have to put the cursor at the beginning of the line, and then hit <b
class="KEYCAP">C</b>-<b class="KEYCAP">k</b> twice: once to delete the text on the line,
once to delete the line itself.</p>
</div>

<div class="NAVFOOTER">
<hr align="LEFT" width="100%" />
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="emacs-modes.html"
accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href="index.html"
accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href="emacs-saving-files.html"
accesskey="N">Next</a></td>
</tr>

<tr>
<td width="33%" align="left" valign="top">Modes</td>
<td width="34%" align="center" valign="top"><a href="emacs.html"
accesskey="U">Up</a></td>
<td width="33%" align="right" valign="top">Saving Files</td>
</tr>
</table>
</div>
</body>
</html>