Alex Rivera | Logout

How to scroll line by line in GNU Emacs?

Asked 2009-07-15T01:23:48.343
112

To put it simply, I'm trying to get scrolling in emacs like in vim and most other editors; when I'm for example, two lines from the bottom/top, and I press down/up (Ctrl-p,n, ↑,↓) it goes only one line up or down, not half the screen.

Edit
Report

2 Answers

63

See some of the suggestions on the Emacs Wiki:

(setq scroll-step            1
      scroll-conservatively  10000)
answered 2009-07-15T01:30:28.817
5

I have the following in my .emacs file to enable a nice ctrl-up, ctrl-down scrolling behavior. I also use this for the mousewheel.

(defun scroll-down-in-place (n)
  (interactive "p")
  (previous-line n)
  (scroll-down n))

(defun scroll-up-in-place (n)
  (interactive "p")
  (next-line n)
  (scroll-up n))

(global-set-key [mouse-4] 'scroll-down-in-place)
(global-set-key [mouse-5] 'scroll-up-in-place)
(global-set-key [C-up] 'scroll-down-in-place)
(global-set-key [C-down] 'scroll-up-in-place)
answered 2009-07-15T19:07:42.527

Your Answer