Use scroll margins to give context to your cursor

I add the following line to my emacs config file so the when I move the cursor near to the top or bottom of the window, the window will scroll when I am 3 lines away from edge. The effect is that (however it is moved) the cursor is always given 3 lines of context before the top or bottom of the window, which I find very useful.

(setq scroll-margin 3)
  • Emacs Watcher

    Back in the dark ages when TPU-mode still worked, you could specify scroll margins as a percentage of the current window. If someone could figure out how to do that I’d love it.