camelCase to snake_case

textmateHere is a TextMate command that will convert all of the selected text from camelCase to snake_case. This command is specifically designed for PHP. Thanks to PHP not having namespaces (until recently) many developers use PEAR naming conventions resulting in code that has class names like BP_Common::fancy_function(). This command will not convert the BP_Common.

Here is the code that you can paste in to the TextMate Bundle Editor as your new command for converting cameleCase variable to snake_case.

One thought on “camelCase to snake_case

  1. Tom Payne says:

    Thanks for this, it was very helpful. However PREG_REPLACE_EVAL is now deprecated so I have used preg_replace_callback instead. Here’s the code I now use.



Leave a Reply

Your email address will not be published. Required fields are marked *