Singletoned
Singletoned

Reputation: 5129

How do I fix the cursor to the middle of the screen in Emacs, so that the page moves, not the cursor?

I'd like to fix the cursor to the centre line of the screen, so that when I press Ctrl-N or Ctrl-P, the page itself moves up or down, and the cursor stays still.

Has anyone got any tips on how to achieve this?

Thanks

Ed

Upvotes: 14

Views: 4149

Answers (4)

mihai
mihai

Reputation: 4742

You can roll your own using the recenter built-in:

(global-set-key (kbd "C-n")
        (lambda (n)
          (interactive "p")
          (next-line n)
          (recenter)))

(global-set-key (kbd "C-p")
        (lambda (n)
          (interactive "p")
          (previous-line n)
          (recenter)))

Upvotes: 1

scottfrazer
scottfrazer

Reputation: 17337

Try centered-cursor mode:

http://www.emacswiki.org/emacs/centered-cursor-mode.el

If you're using MELPA, it's available by M-x package-install RET centered-cursor-mode.

Upvotes: 15

Laurynas Biveinis
Laurynas Biveinis

Reputation: 10856

M-x scroll-lock-mode, which could be used to put the Scroll Lock key to good use too:

(global-set-key (kbd "<Scroll_Lock>") 'scroll-lock-mode)

Upvotes: 11

bendin
bendin

Reputation: 9574

The EmacsWiki page on SmoothScrolling presents some possible solutions.

Upvotes: 4

Related Questions