Function: subword-mode

subword-mode is an autoloaded, interactive and byte-compiled function defined in subword.el.gz.

Signature

(subword-mode &optional ARG)

Documentation

Toggle subword movement and editing (Subword mode).

Subword mode is a buffer-local minor mode. Enabling it changes the definition of a word so that word-based commands stop inside symbols with mixed uppercase and lowercase letters, e.g. "GtkWidget", "EmacsFrameClass", "NSGraphicsContext".

Here we call these mixed case symbols nomenclatures. Each capitalized (or completely uppercase) part of a nomenclature is called a subword. Here are some examples:

  Nomenclature Subwords
  ===========================================================
  GtkWindow => "Gtk" and "Window"
  EmacsFrameClass => "Emacs", "Frame" and "Class"
  NSGraphicsContext => "NS", "Graphics" and "Context"

This mode changes the definition of a word so that word commands treat nomenclature boundaries as word boundaries.

This is a minor mode. If called interactively, toggle the Subword mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate the variable subword-mode(var)/subword-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

View in manual

Probably introduced at or before Emacs version 24.4.

Key Bindings

Aliases

c-subword-mode(var)/c-subword-mode(fun) (obsolete since 23.2) capitalized-words-mode (obsolete since 25.1)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/subword.el.gz
;;;###autoload
(define-minor-mode subword-mode
  "Toggle subword movement and editing (Subword mode).

Subword mode is a buffer-local minor mode.  Enabling it changes
the definition of a word so that word-based commands stop inside
symbols with mixed uppercase and lowercase letters,
e.g. \"GtkWidget\", \"EmacsFrameClass\", \"NSGraphicsContext\".

Here we call these mixed case symbols `nomenclatures'.  Each
capitalized (or completely uppercase) part of a nomenclature is
called a `subword'.  Here are some examples:

  Nomenclature           Subwords
  ===========================================================
  GtkWindow          =>  \"Gtk\" and \"Window\"
  EmacsFrameClass    =>  \"Emacs\", \"Frame\" and \"Class\"
  NSGraphicsContext  =>  \"NS\", \"Graphics\" and \"Context\"

This mode changes the definition of a word so that word commands
treat nomenclature boundaries as word boundaries."
    :lighter " ,"
    (when subword-mode (superword-mode -1))
    (subword-setup-buffer))