Emacs: Move Cursor by camelCase, snake_case

By Xah Lee. Date: . Last updated: .
emacs normal/subword/superword modes.
Cursor position from left to right
normalsubwordsuperword
someThing▮
some▮-thing
some▮_thing
some▮Thing
some▮-thing
some▮_thing
someThing▮
some-thing▮
some_thing▮

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

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

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

To turn them on globally, put this in your emacs init file:

;; move cursor by camelCase
(global-subword-mode 1)
;; 1 for on, 0 for off

Subword mode is new in Emacs 23.2. [see Emacs 23.2 Features (released 2010-05)]

Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

If you have a question, put $5 at patreon and message me.