Skip to content. | Skip to navigation

Personal tools
Sections
You are here: Home Blog Emacs tips: Navigate CamelCase

Emacs tips: Navigate CamelCase

by Ross Patterson last modified Jan 18, 2009 12:13 AM
M-f, M-b, M-d, <M-backspace> over camelCase!

Update: See the comment below about using c-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!

Comments (2)

https://mauritsvanrees.myopenid.com/ Jan 08, 2009 11:49 AM
My colleague Mark was very happy with this, but I got an error (void-function first). Instead I discovered that the standard c-subword-mode works for me. I now have this in my startup file:
(add-hook 'find-file-hook 'c-subword-mode)
Ross Patterson Jan 18, 2009 12:13 AM
Much better! Thanks!
Navigation
OpenID Login

Contact

me@rpatterson.net

IRC: zenwryly@irc.freenode.net
plone.org: rossp
GTalk: mer@patterson.net
Yahoo IM: patterson_ross
AIM: rosspatters
MSN: me@rpatterson.net

PO Box 7775 #10587
San Francisco, CA
94120-7775

Phone
+1 (415) 894-5323