Is there a convenient function for jumping to the last non-tag character in the line of an org-mode heading? For instance...

* This is |my header     :tag1:tag2:

I would like a command that moves the point (|) to:

* This is my header|     :tag1:tag2

Ideally, I would love something that implements a full set of evil motions for this, so that commands like dg_ will not delete tags.


org-end-of-line, bound by default to C-e in org-mode buffers, is probably what you are looking for. The doc string for the function says:

org-end-of-line is an interactive Lisp closure in ‘../org-mode/lisp/org.el’.

It is bound to C-e, <end>.

(org-end-of-line &optional N)

Go to the end of the line, but before ellipsis, if any.

If this is a headline, and ‘org-special-ctrl-a/e’ is not nil or symbol ‘reversed’, ignore tags on the first attempt, and only move to after the tags when the cursor is already beyond the end of the headline.

If ‘org-special-ctrl-a/e’ is symbol ‘reversed’ then ignore tags on the second attempt.

With argument N not nil or 1, move forward N - 1 lines first.

So, in summary, the trick is to (setq org-special-ctrl-a/e t) (or similar) and then use org-end-of-line. Note that this will propagate through to evil-org-end-of-line as well, so all the standard Evil motions will work.

  • 1
    Aha! Thank you! I was already aware of org-end-of-line (via evil-org-end-of-line, which uses it by default for all its motion), but was unaware of the org-special-ctrl-a/e setting, which did what I needed. I revised your answer slightly to highlight that. – Alexey Shiklomanov Jul 20 '18 at 15:00

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.