I want Emacs to scroll on [up] and [down] cursor keys one line at a time.

I have already installed and checked out following packages:

  • smooth-scroll
  • smooth-scrolling
  • good-scroll

Only smooth-scrolling works, but while scrolling down it starts sometimes to jump instead of scrolling by one line.

Is it possible to have a bug-free smooth scrolling one line at a time in Emacs?


P.S. I can't reliably reproduce the problem with the jumps by multiple lines. It occurs preferably in windows with a small number of lines, but sometimes it works OK when only three lines are visible.

Sometimes the position of the point (cursor) changes up and down and this seem to depend on the length of the line and occurs preferably near very long lines (for example 250 chars). This behavior appears to be reproducible, so you can check it out yourself if you are using the smooth-scrolling package.

  • 1
    How about trying (setq scroll-conservatively 101) without any other scroll settings. Most of the old examples combine that setting with other stuff, but I suggest not doing that. To read the doc-string, type C-h v aka M-x describe-variable
    – lawlist
    Commented Mar 28, 2023 at 15:32
  • 1
    @lawlist : if you provide this hint as answer I will accept it. It's worth to have it mentioned here on emacs.stackexchange, so it can be found as answer.
    – oOosys
    Commented Mar 28, 2023 at 17:23
  • 1
    I deleted my second comment because after re-reading the doc-string, it does answer your question as to a value of "101 or 1 or 10 or 120". ... Because 101 and 120 are both greater than 100, they have the same affect; i.e., "redisplay will never recenter point, but will always scroll just enough text to bring point into view, even if you move far away". A value of 1 or 10 (which are less than or equal to 100), means "[s]croll up to this many lines, to bring point back on screen. If point moves off-screen, redisplay will scroll by up to scroll-conservatively lines in order to ...".
    – lawlist
    Commented Mar 28, 2023 at 22:17
  • What try the explanations to say? How can I experience different behavior specifying different values?
    – oOosys
    Commented Mar 28, 2023 at 22:31
  • Anyone here who can confirm moving the position of the point (cursor) while scrolling over very long lines while using smooth-scrolling? Or confirm unpredictable behavior of smooth-scrolling I am speaking about mentioning jumping?
    – oOosys
    Commented Mar 28, 2023 at 22:33

1 Answer 1


Is it possible to have a bug-free smooth scrolling one line at a time in Emacs? How?

Instead of using (prone to bugs) packages use the built-in scroll-conservatively and set its value to 101 in your .emacs (or other init) file:

(setq scroll-conservatively 101)

( Check out C-h o -> scroll-conservatively` for info about why 101 )

Below a proposal of code which scrolls smooth line by line keeping the cursor/point usually (on wrapped lines it doesn't) in the same line near the center of the window. With the additional keybindings for M-<up> and M-<down> it is possible to 'stay' at the cursor keys while vertically repositioning the point on the screen:

;; ---------------------------------------------------------------------
;; Scroll with <up><down> one line at a time keeping the cursor/point 
;; always at the same line near the center of the window: 
(global-set-key (kbd "<down>") (lambda (&optional ARG TRY-VSCROLL) (interactive "^p\nP") (next-line     ARG TRY-VSCROLL) (recenter)))
(global-set-key (kbd "<up>")   (lambda (&optional ARG TRY-VSCROLL) (interactive "^p\nP") (previous-line ARG TRY-VSCROLL) (recenter)))
(global-set-key (kbd "M-<up>"  ) 'previous-line)
(global-set-key (kbd "M-<down>") 'next-line)

You can put the above code into your .emacs file and enjoy the new navigation feature, but ...

... be warned that it was not extensively tested, so there is a chance that in some edge cases it does not work as expected.

Anyway in the preliminary tests these four lines of code worked better than the for smooth scrolling available packages.

Thanks goes to @Shynur for providing the core of the code used above.

Notice that the code above in combination with the follow-mode provides the feature of keeping the cursor/point in one of the multiple windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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