Capitalizing first letter with multiple cursors in sublime
In sublime, if I use cmd + D to select each "old" case, the selection is case insensitive, so old and camel old will match . But when I start typing, the capitalization is not respected, so I get a new one and camel a new one . Are there any shortcuts or plugins to get the sublime value to keep the first letter when typing using multiple cursors?
- Choose your word
- Select all the cases you want to change (
ctrl+d
) - Open Find> Replace (
ctrl+h
) - Check "in selection" and "keep case" (
alt+a
), uncheck regex (alt+r
) and other things you don't need - Go to the bottom field, write your replacement
- Replace all
There are hotkeys for all steps except "toggle_in_selection". You can put this in your keys to fix it:
{ "keys": ["alt+s"], "command": "toggle_in_selection", "context":
[
{ "key": "setting.is_widget", "operator": "equal", "operand": true }
]
},
NOTE: Change the shortcut to whatever works best for you.
Alternatively, you can put this in your keys:
{ "keys": ["ctrl+h"], "command": "show_panel", "args": {"panel": "replace", "in_selection": true, "preserve_case": true, "regex": false, "highlight": true} },
with custom shortcut. You can use the original shortcut to overwrite its default behavior.
It will prepare all these switches and checks for you, so you can simply
- Choose
-
ctrl+d
all occurrences - use this shortcut
- to go to the bottom margin write replace
-
ctrl+alt+enter
to replace everything
... be careful with "replace all"
There is a Sublime plugin to help you make this a little easier:
https://github.com/philippotto/Sublime-MultiEditUtils
The case save code was just leaked today.
See the heading "Preserve Case While Editing Selection Content"