Emacs Advent Calendar 01: Moving around in Text
Everyone knows how to move around in texts using the arrow keys. Unsurprisingly this also works in Emacs, but there are tons of additional keybindings to take advantage of. Learning at least some of them enables you to move around without having to lift your hand away to the arrow keys.
C-f move point (Emacs' name for
the cursor) one character to the left and to the right
C-n advances point one
line up or down. Thinking of the directions as "backward", "forward",
"previous" and "next" can serve as a mnemonic.
M-f moves point left or right one word
at a time.
Several commands exist that move point by lines. The command
C-a moves point to the beginning of the current line (like
C-e jumps to the end of it (like End). The commands
M-> move point to the first or last line of
the whole buffer.
Scrolling the buffer is done with
the first one moves down one screen, the second one moves up.
M-g g (
M-g M-g also works) makes Emacs ask
for a line number to directly move point to.
Finally there is one thing to keep in mind: When lines are longer than
the width of the window, Emacs wraps them around by default. Thus one
logical line can take the space of multiple screen lines. Most
commands operate on logical lines (e.g.
but for some others (like
C-p) it is more
useful to work on screen lines.
All of these commands and some more are described in section 7.2 (Changing the Location of Point) in the Emacs Reference Manual.Tags: emacs
This text by Ludger Sandig is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.