Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted

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.

share|improve this answer
add comment

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-{).

share|improve this answer
add comment
C-u PERCENT M-x View-goto-percent

moves the cursor PERCENT of the way through of buffer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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