I want to have w/ expand to with globally.

Defining the abbrev in the usual way works (e.g. typingwith C-x ag w/), and the entry in the abbrev_defs file looks fine - output of M-x list-abbrevs under (global-abbrev-table):

"with"         0    "w/"

However, typing "w/" in abbrev-mode or even manually trying to expand this using C-x ' does not work. Why is that and how can I change it?

  • Sorry, abbrev only allow sequence of English letters to be used as input. / can expand a abbrev like , or space...
    – djangoliv
    Commented Oct 20, 2015 at 13:23
  • @djangoliv Although "sequences of english letters" (word syntax in emacs terminology) behaviour is default, it can be customized. See my own answer. Commented Oct 20, 2015 at 22:04

2 Answers 2


I think I found a solution without modification of the syntax-table.

From the GNU Emacs Manual - Sect. 35.7 Abbrev Table Properties:



If this property is nil, the default is to use backward-word and forward-word to find the name. This property allows the use of abbrevs whose name contains characters of non-word syntax.

I.e. it is only the default behaviour that non-word syntax is used to define the abbrev "boundaries", but this can be configured.

And indeed:

(abbrev-table-put org-mode-abbrev-table :regexp "\\(\\\\[a-z0-9@]+\\)")

lets me insert abbrevs with leading and trailing slashes in org-mode. (For other modes, or globally org-mode-abbrev-table needs to be replaced accordingly)

(With help from reddit: https://www.reddit.com/r/emacs/comments/3pi8wx/abbrevmode_expansion_with_trailing_does_not_work/ )


Expanding on djangoliv's comment, "you cant'': abbrev's expands the last word and the "/" is not considered a word character.

Try this. Put this in a buffer:

abc/ def/ghi

and then move by word (Meta-F and Meta-B). You'll see that "abc" "def" and "ghi" is moved over, but we stop at the slash.

You can however modify what emacs-considers a word character via M-x modify-syntax-entry / w. Then when you move word you'll see that / is included in the word.

See http://emacswiki.org/emacs/EmacsSyntaxTable for more information on syntax tables.

  • That appears like a very radiacal approach to me. I would prefer a solution that woult not alter the behaviour which you demonstrate - i.e. forward-word and backward-word work as "shipped" by emacs. Commented Oct 20, 2015 at 15:40
  • 2
    @ChristianHerenz I was merely explaining the behavior and showing you how you could determine what is considered a word. I was not necessarily suggesting you edit the syntax table. I should note that various modes that emacs uses do in fact alter syntax tables. If you feel that altering a global or local syntax table is radical, then djangoiv's comment holds: short of other equally radical approaches, you can't do this. Alter your abbrev.
    – rocky
    Commented Oct 20, 2015 at 15:44
  • To explain, why I dislike changing the syntax table in this way - then forward-word / backward-word messes up in path-names and URLs. The w/ "mnemonic" I use since a long time in my note-taking - and I recently discovered abbrev mode - so I thought I could add a little bit of magic to my daily life by expanding this using abbrevs.... I'm sad to hear that it appears to be next to impossible. Commented Oct 20, 2015 at 19:30

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.