Emacs Recentering With Context

April 13th, 2022
emacs, tech
In emacs, when you press Ctrl-L, by default it runs recenter-top-bottom. This scrolls the document ("buffer") so the line the cursor is currently on is centered in the screen. If you press it again, it scrolls so the cursor is at the very top of the screen, and again puts the cursor at the very bottom. I've always been mildly irritated by this: the middle of the screen is lower than I want for the initial state; I generally want more context below the cursor than above. Additionally, scrolling to the top or bottom is nearly useless because I almost always want at least a little bit of context on both sides of the cursor.

Everything in emacs can be configured, but sometimes it's quite a pain, so I kept putting off looking into this. With Nora napping and the older two playing with a neighbor friend, however, I finally looked into this, and it turns out to be very easy. There's a recenter-positions variable that defaults to '(middle top bottom), but you can set it to anything you want. The default is equivalent to '(0.0, 0.5, 1.0), and I'm now using:

(setq recenter-positions '(0.25 0.5 0.9))
This means that the first Ctrl-L puts my cursor 25% of the way down the page, which is where I'm most likely to want it. If I find I want more context above I can press it again, to put it at 50%, and again to put it at 90%.

These are good for my usage, but I run tall terminals and if I ran shorter ones I might want different values.

Comment via: facebook, lesswrong

Recent posts on blogs I like:

Starting With Chords

A lot of people play fiddle. Basically nobody starts by learning chords before learning melodies. But that's actually how I learned. I started with chords. One of the nice things about learning to play violin this way is that you can go busking even…

via Anna Wise's Blog Posts November 15, 2024

Stuffies

I have some stuffies and I just have a bunny. Bunny is a rabbit. Woof is a seal. My favorite stuffie is bun bun. I play with my stuffies. Sometimes I jump up with them and I roll them. I can just throw them in the air when I want to play bthululubp wi…

via Nora Wise's Blog Posts November 15, 2024

You Can Buy A Malaria Net

2024 election takes

via Thing of Things November 6, 2024

more     (via openring)