The tab-to-tab-stop command moves the point to the next tabstop; I can't find an equivalent to move to the previous tabstop and tab-to-tab-stop doesn't accept a universal argument to reverse direction.

1 Answer 1


Indeed, looking at the source for tab-to-tab-stop,

(defun tab-to-tab-stop ()
  (and abbrev-mode (= (char-syntax (preceding-char)) ?w)
  (let ((nexttab (indent-next-tab-stop (current-column))))
    (delete-horizontal-space t)
    (indent-to nexttab)))

it would only need to accept an optional prefix argument to pass to indent-next-tab-stop in order to achieve the requested bidirectionality, like so:

(defun my-tab-to-tab-stop (&optional prev)
  "Like `tab-to-tab-stop', but toggle direction with prefix."
  (interactive "P")
  (let ((nexttab (indent-next-tab-stop (current-column) prev)))
    (delete-horizontal-space t)
    (indent-to nexttab)))

I think the function is simple enough that you can redefine/rebind it yourself as I have shown (I left out the abbrev-mode stuff because I don't think it makes sense to expand things when indenting backwards).

You could also look into submitting this as a feature request (I am not familiar with the process).

  • 1
    M-x report-emacs-bug for feature requests.
    – phils
    Jul 14, 2017 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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