VS Code: Case sensitive replacement after pressing Crtl - D

Viewed 13597

Let's suppose I have the following code:

enter image description here

But I change my mind and I don't want to call it plan anymore. I want to call it schedule. So, because VS Code is so amazing and I'm so lazy, I press <Ctrl - D> hoping for VS Code to change the name respecting the case. But suddenly:

enter image description here

Is it there any way to tell VS Code to respect the case?

6 Answers

With 1.37 (July 2019), it is possible through a find/replace (which now can replace by preserving case).

From 1.37 release notes:

You can now preserve case when doing replacement in the editor's Find widget. The feature is turned on when the Preserve Case option (AB button) is turned on in the editor's Replace input box.

https://code.visualstudio.com/assets/updates/1_37/preserve-case-button.png

Currently VS Code only supports preserve Full Upper Case, Full Lower Case, and Title Case.

Shortcuts are Alt + C for case sensitive. There is a little toolbar appears at the top-right corner of the VS Code, to let you toggle search options.

enter image description here

or you just Ctrl + F to toggle replace mode.

enter image description here

As far as I know it isn't, a workaround could be using the buttons that appear on top right after you press Ctrl + D. The second lets you select occurrences respecting the case, this way you could replace the text in 2 steps, first Plan and then plan.

So select the code bit, ctrl+h to open replace, edit find and replace, turn off match case in find, turn on preserve case within replace, Alt+L to find all occurences in selection, and Ctrl+Alt+Enter to execute.

9/10 cases you'll get it wrong, doesn't worth the effort. Just use ctr+d, then do the same for the uppercase.

Personally looking forward for a simpler/safer solution through the ctrl+d way. :)

Related