Here 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.
#!/usr/bin/env php
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.
Thanks!
Tom.