Книга: Learning GNU Emacs, 3rd Edition

2.1.2 Moving a Screen (or More) at a Time

2.1.2 Moving a Screen (or More) at a Time

Like other graphical applications, you can use the scrollbar to move around in Emacs. Like most things in Emacs, in addition to using the mouse or scrollbar to move around, you should learn Emacs's own keyboard commands to maximize your productivity.

If you want to page through a file one screen at a time, use the PgDown key or type C-v. Emacs displays the next full screen from your file. It leaves a couple of lines from the previous screen at the top to give you a sense of context. Likewise, pressing M-v (or the PgUp key) shows you the previous screen. Together, M-v and C-v provide a convenient way to scroll through a file quickly.

Scrolling happens automatically if you type any motion command that takes you beyond the limits of the text currently displayed. For example, if you are on the last line of the screen and press C-n, Emacs scrolls forward. Similarly, if you are at the top of the screen and press C-p, Emacs scrolls backward.

You often want to move all the way to the beginning or the end of a file. Type M-> or press End to go to the end of a buffer. To go to the beginning, type M-< or press Home. It may help you to remember that > points to the end of the buffer, and < points to the beginning of the buffer.

There are two more ways to move around that may come in handy. M-x goto-line Enter nEnter moves the cursor to line n of the file. Of course, Emacs starts counting lines from the beginning of the file. Likewise, M-x goto-char Enter nEnter goes to the nth character of the file, counting from the beginning. In both cases, n is a number.

For programmers, these commands are useful because many compilers give error messages like Syntax error on line 356. By using these commands, you can move easily to the location of your error. There are some more sophisticated ways to link Emacs with error reports from compilers and other programs. In addition, several other cursor motion commands are applicable only when you are editing programs (see Chapter 9 for details).

Оглавление книги


Генерация: 1.255. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз