Emacs: subword-mode, superword-mode, camelCase, snake_case

By Xah Lee. Date: . Last updated: .
emacs subword-mode superword-mode camelCase snake case
emacs subword-mode, superword-mode

emacs has subword-mode. It change all cursor movement/edit commands to stop in-between the “camelCase” words.

superword-mode (emacs 24.4) is similar. It treats text like “x_y” as one word. Useful for “snake_case”.

subword-modesuperword-mode are mutally exclusive. Turning one on turns off the other.

To see whether you have subword-mode on, call describe-variable then type “subword-mode”. Same for superword-mode.

To turn it on, just call subword-mode. Call again to turn off.

Or put in emacs init file:

;; move cursor by camelCase
(subword-mode 1) ; 1 for on, 0 for off
Like it? Buy Xah Emacs Tutorial. Thanks.