I use:

(global-superword-mode t)

in my init.el because I don't want Emacs to treat _ as a word delimiter.

How do I do the same thing for -? I'd like to enable this globally.

1 Answer 1


(global-superword-mode t)

[Note that mode functions are not documented as accepting t as argument - you should enable modes either as (mode) or with a non-zero natural number such as (mode 1).]

How do I do the same thing for -?

That depends on the syntax table (see (info "(elisp) Syntax Tables")), and thus the modes, in use. AFAICT, superword-mode delegates all of its boundary finding to the command forward-symbol. So if forward-symbol recognises - as constituting a symbol, then so will superword-mode.

In Elisp, - already has symbol syntax (see C-u C-x =, C-h s) so forward-symbol will skip all of e.g. global-superword-mode in one go. This is also the case in e.g. fundamental-mode and text-mode.

For changing the syntax category of -, there's the command modify-syntax-entry; see (info "(elisp) Syntax Table Functions"). For example, you could do M-x modify-syntax-entry RET - _ RET to give it symbol syntax in the current buffer.

  • Thanks! Is there anything I can add to init.el to have this set automatically? Commented Dec 4, 2020 at 14:46
  • @WickedJargon Depends on where you would want such a setting to take effect - which modes, buffers, etc. Once you have identified these, then you can add the corresponding calls to (modify-syntax-entry ...) to the corresponding mode hooks or with-eval-after-load stanzas.
    – Basil
    Commented Dec 4, 2020 at 14:51
  • How do I enable it globally? Commented Dec 4, 2020 at 22:22
  • @WickedJargon Maybe you could add the call to (modify-syntax-entry ..) on after-change-major-mode-hook, so that it runs in every mode.
    – Basil
    Commented Dec 5, 2020 at 10:03

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.