In Intellij, how do I toggle between camel case and underscore spaced?
Solution 1:
Two plugins offer this feature:
I use a plugin called String Manipulation which does what you need (and more).
Select historyOfPresentIllness
and press Alt / option+M to bring up the plugin menu, then press:
-
5 - To snake_case (or to camelCase) which converts to
history_of_present_illness
-
6 - To hyphen-case (or to snake_case) which converts to
history-of-present-illness
To make this easier, you could set up a shortcut at File | Settings | Keymap
.
There also is the [CamelCase][3] plugin.
SHIFT+Alt / option+U toggles the selection between formats:
historyOfPresentIllness
--> history_of_present_illness
--> HISTORY_OF_PRESENT_ILLNESS
--> HistoryOfPresentIllness
--> historyOfPresentIllness
You can also undo your changes (now that a bug in the plugin got fixed).
Solution 2:
Very simple press Clr + F
to open Find/Replace panel and check [✓] Regex copy past regex
Find: [_]{1,1}([a-z])
Replace: \U$1
Press [Replace all] button, Enjoy
Thanks @piotrek for _some_awe_var
to _someAweVar
Use Find: (\w)[_]{1,1}([a-z])
Replace: $1\U$2