4

I am new to emacs and I am using evil mode.

When I scroll with j,k and I move out of the screen, emacs will readjust the current line under the cursor to the middle of the screen.

Where can I disable this feature?

Maik Klein
  • 15,548
  • 27
  • 101
  • 197
  • 2
    How about?: `(setq scroll-conservatively 101)` "*If the value is greater than 100, 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 zero means always recenter point if it moves off screen.*" – lawlist Sep 10 '14 at 13:17
  • @lawlist That seems to do it. – Maik Klein Sep 10 '14 at 13:19
  • Glad to help. I'll wait and see what the others want to do with this question before posting an answer, because there are several that are somewhat similar and it may be marked as being a "duplicate". – lawlist Sep 10 '14 at 13:29
  • 1
    possible duplicate of [How to scroll line by line in GNU Emacs?](http://stackoverflow.com/questions/1128927/how-to-scroll-line-by-line-in-gnu-emacs) – Randy Morris Sep 10 '14 at 19:27
  • 1
    @lawlist Even if it'll be likely closed, having one answer will help someone coming from google. They may not look to the comments for an answer. – event_jr Sep 11 '14 at 01:38

1 Answers1

10

By adding the following setting to the .emacs file (or similar user customization file -- e.g., init.el), the user can override the default setting that recenters point as it moves off the screen:

(setq scroll-conservatively 101)

The doc-string for scroll-conservatively, which is visible by typing M-x describe-variable RET scroll-conservatively RET reads as follows (at least in so far as a developer snapshot of Emacs Trunk goes, that is):

"If the value is greater than 100, 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 zero means always recenter point if it moves off screen."

lawlist
  • 13,099
  • 3
  • 49
  • 158
  • 2
    This works very nicely with `(setq scroll-margin 20)`, to create a top/bottom margin, above/below which scrolling starts to happen. – edam Jun 10 '15 at 12:12
  • For the full story, see [Automatic scrolling](https://www.gnu.org/software/emacs/manual/html_node/emacs/Auto-Scrolling.html) in the manual. – Michael Allan Jan 18 '21 at 11:58