To do more than insert characters, you have to know how to move point (see Point). The keyboard commands C-f, C-b, C-n, and C-p move point to the right, left, down, and up, respectively. You can also move point using the arrow keys present on most keyboards: RIGHT, LEFT, DOWN, and UP; however, many Emacs users find that it is slower to use the arrow keys than the control keys, because you need to move your hand to the area of the keyboard where those keys are located.
You can also click the left mouse button to move point to the position clicked. Emacs also provides a variety of additional keyboard commands that move point in more sophisticated ways.
Move forward one character (forward-char
).
This command (right-char
) behaves like C-f, except when
point is in a right-to-left paragraph (see Bidirectional Editing).
Move backward one character (backward-char
).
This command (left-char
) behaves like C-b, except if the
current paragraph is right-to-left (see Bidirectional Editing).
Move down one screen line (next-line
). This command attempts
to keep the horizontal position unchanged, so if you start in the
middle of one line, you move to the middle of the next.
Move up one screen line (previous-line
). This command
preserves position within the line, like C-n.
Move to the beginning of the line (move-beginning-of-line
).
Move to the end of the line (move-end-of-line
).
Move forward one word (forward-word
). See Words.
This command (right-word
) behaves like M-f, except it
moves backward by one word if the current paragraph is
right-to-left. See Bidirectional Editing.
Move backward one word (backward-word
). See Words.
This command (left-word
) behaves like M-b, except it
moves forward by one word if the current paragraph is
right-to-left. See Bidirectional Editing.
Without moving the text on the screen, reposition point on the left
margin of the center-most text line of the window; on subsequent
consecutive invocations, move point to the left margin of the top-most
line, the bottom-most line, and so forth, in cyclic order
(move-to-window-line-top-bottom
).
A numeric argument says which screen line to place point on, counting downward from the top of the window (zero means the top line). A negative argument counts lines up from the bottom (−1 means the bottom line). See Numeric Arguments, for more information on numeric arguments.
Move to the top of the buffer (beginning-of-buffer
). With
numeric argument n, move to n/10 of the way from the top.
On graphical displays, C-HOME does the same.
Move to the end of the buffer (end-of-buffer
). On graphical
displays, C-END does the same.
Scroll the display one screen forward, and move point onscreen if
necessary (scroll-up-command
). See Scrolling.
Scroll one screen backward, and move point onscreen if necessary
(scroll-down-command
). See Scrolling.
Read a number n and move point to buffer position n. Position 1 is the beginning of the buffer. If point is on or just after a number in the buffer, that is the default for n. Just type RET in the minibuffer to use it. You can also specify n by giving M-g c a numeric prefix argument.
Read a number n and move point to the beginning of line number
n (goto-line
). Line 1 is the beginning of the buffer. If
point is on or just after a number in the buffer, that is the default
for n. Just type RET in the minibuffer to use it. You can
also specify n by giving M-g M-g a numeric prefix argument.
See Creating and Selecting Buffers, for the behavior of M-g M-g when you give it
a plain prefix argument. Alternatively, you can use the command
goto-line-relative
to move point to the line relative to the
accessible portion of the narrowed buffer.
goto-line
has its own history list (see Minibuffer History). You can have either a single list shared between all
buffers (the default) or a separate list for each buffer, by
customizing the user option goto-line-history-local
.
Read a number n and move to column n in the current line. Column 0 is the leftmost column. If called with a prefix argument, move to the column number specified by the argument’s numeric value.
Use the current column of point as the semipermanent goal column
(set-goal-column
) in the current buffer. When a semipermanent
goal column is in effect, C-n, C-p, <prior> and
<next> always try to move to this column, or as close as
possible to it, after moving vertically. The goal column remains in
effect until canceled.
Cancel the goal column. Henceforth, C-n and C-p try to preserve the horizontal position, as usual.
When a line of text in the buffer is longer than the width of the
window, Emacs usually displays it on two or more screen lines,
a.k.a. visual lines. For convenience, C-n and C-p
move point by screen lines, as do the equivalent keys down
and up. You can force these commands to move according to
logical lines (i.e., according to the text lines in the buffer)
by setting the variable line-move-visual
to nil
; if a
logical line occupies multiple screen lines, the cursor then skips
over the additional screen lines. For details, see Continuation Lines. See Variables, for how to set variables such as
line-move-visual
.
Unlike C-n and C-p, most of the Emacs commands that work
on lines work on logical lines. For instance, C-a
(move-beginning-of-line
) and C-e
(move-end-of-line
) respectively move to the beginning and end
of the logical line. Whenever we encounter commands that work on
screen lines, such as C-n and C-p, we will point these
out.
When line-move-visual
is nil
, you can also set the
variable track-eol
to a non-nil
value. Then C-n
and C-p, when starting at the end of the logical line, move to
the end of the next logical line. Normally, track-eol
is
nil
.
C-n normally stops at the end of the buffer when you use it on
the last line in the buffer. However, if you set the variable
next-line-add-newlines
to a non-nil
value, C-n on
the last line of a buffer creates an additional line at the end and
moves down into it.