In sublime if I use cmd+D to select every occurrence of 'old' the selection is case insensitive so will match old and camelOld. But when I start typing the capitalisation is not respected so i will get new and camelnew. Are there any shortcuts or plugins to get sublime to preserve first letter capitalisation when typing using multiple cursors?
Asked
Active
Viewed 1,329 times
4
-
1I wish this was the default behavior. – stephen.hanson Jan 15 '15 at 19:22
2 Answers
7
- Select your word
- Select all occurences you want to change (
ctrl+d
) - Open Find > Replace (
ctrl+h
) - Check "in selection" and "preserve case" (
alt+a
), uncheck regex (alt+r
) and other stuff you don't want - Go to lower field, write your replacement
- Replace all
There are key shortcuts for all the steps except for "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 suits you best.
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 it's default behavior.
It will prepare all those toggling and checking for you, so you can just
- Select
ctrl+d
all occurrences- use this shortcut
- tab to go to lower field, write your replacement
ctrl+alt+enter
to replace all
...be careful, with "replace all"

WOUNDEDStevenJones
- 5,150
- 6
- 41
- 53

enrey
- 1,621
- 1
- 15
- 29
3
There is a Sublime plugin that will help you do this a bit easier:
https://github.com/philippotto/Sublime-MultiEditUtils
The case preservation code was just merged today.
See the heading "Preserve case while editing selection contents"

Tim Krins
- 3,134
- 1
- 23
- 25