I want to type "--> " and have it automatically converted into "→ ". Is there a way to do this using Abbrev?

  • Do you mean expand —> to \rightarrow?
    – Melioratus
    Commented Jun 23, 2018 at 5:02

2 Answers 2


From emacs manual:

More precisely, any character that is not a word constituent expands an abbrev, and any word-constituent character can be part of an abbrev.

So the answer is no because characters '-' and '>' are not word characters.

Instead, do come up a with naming schema that is easy to remember. I am using the convention from Xah Lee to start Unicode abbrevs with character 8 and use a short mnemonic string. For example, add this into your global-abbrev-table:

("8ar" "→" nil 0)
  • Yes, I'm thinking about what to change in abbrev.el so that what's a "word" can be defined by the user. It seems that abbrev.el uses the regexp "\\w+". My suggestion for the developers would be to make this user-configurable. I f.ex., would like to set it to "[a-zA-Z0-9<>-]+". Commented Jun 27, 2018 at 15:46

Using abbrev, not really. You can do it yourself though:

(defun my-insert-gt ()
  "Substitute in arrow maybe."
  (if (looking-back "--" (- (point) 2))
        (backward-delete-char 2)
        (insert "→"))
    (insert ">")))
(global-set-key ">" #'my-insert-gt)

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.