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?)


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.


Some thoughts:

A fast way to navigate is to use incremental search (C-s) and its variants.

I wonder if occur can be useful for navigating between matches on such large files. It shows a separate window with all occurrences of a match regexp, which you can navigate with M-g n and M-g p.

For jumping to percentage of buffer, http://www.emacswiki.org/emacs/basic-edit-toolkit.el has a function for this:

(defun goto-percent (percent)
  "Goto PERCENT of buffer."
  (interactive "nGoto percent: ")
  (goto-char (/ (* percent (point-max)) 100)))

forward-paragraph and backward-paragraph may also be useful for fast navigation, depending on the file structure (bound to M-} and M-{).

C-u PERCENT M-x View-goto-percent

moves the cursor PERCENT of the way through of buffer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.