Movement for Reading in Emacs

I use the usual emacs keybindings for moving the cursor around in the buffer. Usually this is more about positioning the cursor for making edits, but more and more I find myself using emacs for non-editing tasks. In these cases I am less concerned with where my cursor is and more so with what text is visible in the buffer window.

My many years of Visual Studio had taught me to hold control and press the up or down arrow when I wanted to scroll the buffer and keep my cursor in the same place. I was in erc reading a log of overnight IRC messages when this impulse came surging back.

So here's how I solved it. I decided to depart from Visual Studio's behavior and just keep the cursor moving along with me.

(defun move-and-center ()
  (interactive)
  (forward-line)
  (scroll-up 1))
(global-set-key (kbd "M-<RET>") 'move-and-center)

Control is a hotly contested modifier key, so I figured I would try meta instead. It is also convenient enough since I won't be doing much else while I'm reading.

Then I realized I also wanted to move up in the same way (surprise!) so I added another function:

(defun move-and-center-reverse ()
  (interactive)
  (forward-line -1)
  (scroll-up -1))
(global-set-key (kbd "M-\\") 'move-and-center-reverse)

This time I used the \ key because it was close enough and I didn't have to use another modifier key.

We'll see how it goes.

Show Comments