Scrolling on very long files (1M+ lines) on Emacs

emacskeyboard shortcuts

I was wondering if besides the basic navigation commands:

C-p : Jump backwards one line.
C-n : Jump forward one line.
C-v : Jump forward one full screen.
M-v : Jump backwards one full screen.
M-a : Go to the previous paragraph beginnings.
M-e : Go to the next paragraph end.
M-g g: Jump to a specific line

emacs provides any commands to easily scroll thousands or millions of lines.

More specifically, I am looking for example for a command that I could use to move forward (or backwards) 1% of the file (maybe a command that can be combined with C-u and can be used to scroll an arbitrary % of the file?)

Best Answer

The commands beginning-of-buffer (C-home or M-<) and end-of-buffer (C-end or M->) take a numeric argument. If the argument is N, then the command takes you N/10 of the way. (With some rounding: these commands take you to the beginning of a line.) For example, M-1 M-> goes to the 90% position in the buffer, i.e. around line 900000 in a million-line buffer.

For more precise control, you can scroll to the end, note the line number, and use M-g g (goto-line) to reach a particular line number, e.g. ESC 9 0 0 0 ESC g g to go to line 9000.

Related Question