Next: , Previous: , Up: Commands   [Contents][Index]

4.9 Subword Movement and Editing

In spite of the GNU Coding Standards, it is popular to name a symbol by mixing uppercase and lowercase letters, e.g., ‘GtkWidget’, ‘EmacsFrameClass’, or ‘NSGraphicsContext’. Here we call these mixed case symbols nomenclatures. Also, each capitalized (or completely uppercase) part of a nomenclature is called a subword. Here are some examples:

NomenclatureSubwords
———————————————————
GtkWindowGtk’ and ‘Window
EmacsFrameClassEmacs’, ‘Frame’, and ‘Class
NSGraphicsContextNS’, ‘Graphics’, and ‘Context

The subword minor mode replaces the basic word oriented movement and editing commands with variants that recognize subwords in a nomenclature and treat them as separate words:

KeyWord oriented commandSubword oriented command
—————————————————————————-
M-fforward-wordc-forward-subword
M-bbackward-wordc-backward-subword
M-@mark-wordc-mark-subword
M-dkill-wordc-kill-subword
M-DELbackward-kill-wordc-backward-kill-subword
M-ttranspose-wordsc-transpose-subwords
M-ccapitalize-wordc-capitalize-subword
M-uupcase-wordc-upcase-subword
M-ldowncase-wordc-downcase-subword

Note that if you have changed the key bindings for the word oriented commands in your .emacs or a similar place, the keys you have configured are also used for the corresponding subword oriented commands.

Type C-c C-w to toggle subword mode on and off. To make the mode turn on automatically, put the following code in your .emacs:

(add-hook 'c-mode-common-hook
          (lambda () (subword-mode 1)))

As a bonus, you can also use subword-mode in non-CC Mode buffers by typing M-x subword-mode.

Next: Other Commands, Previous: Hungry Deletion of Whitespace, Up: Commands   [Contents][Index]