8

The command C-l scrolls the current line to center, top, bottom. Is there an analogous command that scrolls the current column to center, left, and right?

Brian Fitzpatrick
  • 2,325
  • 1
  • 20
  • 42

1 Answers1

4

There doesn't seem to be one built-in, however, there is something similar: M-g TAB - this will ask you for the column to move to. You can use the function below (bind it to some key you like) to do exactly what you ask:

(defun my/goto-midline ()
  (interactive)
  (goto-char
   (+ (point)
      (save-excursion
        (/ (- (progn
                (move-end-of-line 1) (point))
              (progn
                (move-beginning-of-line 0) (point)))
           2)))))
wvxvw
  • 11,342
  • 2
  • 31
  • 56