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?

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)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.