replaceFirst() method to convert the given string from snake case to camel case. First, capitalize the first letter of the string. Run a loop till the string contains underscore (_). Replace the first occurrence of a letter that present after the underscore to the capitalized form of the next letter of the underscore.
To navigate backwards, press Ctrl+Alt+Left . To navigate forward, press Ctrl+Alt+Right . To navigate to the last edited location, press Ctrl+Shift+Backspace . To find the current caret location in the editor, press Ctrl+M .
To toggle between upper case and lower case Select text fragment, or just place the caret at the line you want to change case in. Press Ctrl+Shift+U or choose Edit | Toggle Case in the main menu . CamelCase names are converted to the lower case.
What is CamelCase? CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces. It is commonly used in web URLs, programming and computer naming conventions. It is named after camels because the capital letters resemble the humps on a camel's back.
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:
history_of_present_illness
history-of-present-illness
To make this easier, you could set up a shortcut at File | Settings | Keymap
.
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).
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
(\w)[_]{1,1}([a-z])
$1\U$2
([A-Z])
\_\L$1
If you are OK with PyCharm also refactoring usages, launch the "Rename" tool (Refactor > Rename). The window pops up with drop down list and you should see the snake_case version of the text in the list (you can open the window and switch to the snake_case with key-strokes so it can be pretty fast).
Answer above is almost perfect, but note that it will change variables like _something
or this._something
into Something
and this.Something
. I didn't want that in my case, as leading _ was used to denote "private" variables (old JS project). I slightly modified this approach:
Find: (\w)[_]{1,1}([a-z])
Replace: $1\U$2
This will ensure that only variables with _
is in the middle will be affected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With