Emacs tips: Navigate CamelCase

M-f, M-b, M-d, <M-backspace> over camelCase!

Update 2: See comment below about c-subword-mode being renamed to subword-mode.

Update: See the comment below about using subword-mode. It’s already included in my emacs at least, and it seems to be a bit better supported. camelCase-mode seems to conflict with org-mode at least.

I’m terribly behind on my blogging but I wanted to re-post this nice little tidbit from Planet Python for those who aren’t on it already. The camelCase-mode for emacs allows you to do most word based operations over the separate words that make up a camel case word.

I’ve been needing something like this for some time. As an emacs junkie, I’ve gotten quite accustomed to being able to move point pretty much directly where I want it in just a few key strokes. Camel case words, however, can get quite long so correcting a typo or changing a plural in one of the constituent words can leave me reaching for my mouse of hammering away at C-f or C-b. Simply unacceptable! :)

So I downloaded camelCase.el to /usr/local/share/emacs/site-lisp and then added the following to my .emacs:

(require 'camelCase)
(add-hook 'find-file-hook 'camelCase-mode)

Ta da! CamelCaseGoodness!

Updated on 09 September 2012

Imported from Plone on Mar 15, 2021. The date for this update is the last modified date in Plone.

Comments

comments powered by Disqus