HowTo Change camelCase() to camel_case() with Emacs

Go to the top of your file, unless you want to do regexp replace in many files, then press Meta-Ctrl-% to enter regexp-replace mode. Then enter the following:

   \([a-z]+\)\([A-Z]\)
Then press <CR> and enter the replacement text:
   \1_\,(downcase \2)

The trick to use Emacs lisp was found here.

Update: For an even better ways of dealing with CamelCase, see the EmacsWiki topic. :-)

Wednesday, 10 February 2010 at 08:50 | /emacs | permanent link to this entry