The recenter command in emacs is recenter-top-bottom which I can invoke using Ctrl-l. How can I call this command automatically every time the cursor is on the fifth-last line in the visible frame?


I am manually editing one column in a large csv file with 4000 rows and I have turned on overwrite mode and I have remapped the 0 and 1 keys so that they automatically add a new line, like this:

(local-set-key (kbd "1") (lambda () (interactive)
 (self-insert-command 1) (next-line) (left-char)))

So I don't have to press any arrow keys. One last thing that I want to automate is the recentering.

  • 2
    Have a look at the variable scroll-margin.
    – lawlist
    Commented Apr 22, 2019 at 1:39
  • Thanks for the pointer :)
    – Pushpendre
    Commented Apr 22, 2019 at 8:16


Your Answer

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

Browse other questions tagged or ask your own question.