Emacs: Move Cursor by camelCase, snake_case

By Xah Lee. Date: . Last updated: .

You can set emacs so that word moving commands will move cursor into between CamelCaseWords, or tweet snake_case as one single word.

Alt+x subword-mode
Change all cursor movement/edit commands to stop in-between the “camelCase” words.
Alt+x superword-mode
Change all cursor movement/edit commands to treat text like “x_y” as one word. Useful for “snake_case”.
Alt+x global-subword-mode
Toggle on/off globally.
Alt+x global-superword-mode
Toggle on/off globally.
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▮

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

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode


Emacs Init

Init Basics

packages

text editing

file

appearance

misc