VSCode:按 Ctrl - D 后进行区分大小写的替换

VS Code: Case sensitive replacement after pressing Crtl - D

假设我有以下代码:

但是我改变主意了,我不想再叫它plan了。我想叫它schedule。所以,因为 VS Code 太棒了,我又太懒了,我按 <Ctrl - D> 希望 VS Code 能根据大小写更改名称。但是突然间:

有没有办法让 VS Code 尊重大小写?

据我所知,解决方法是使用按下 Ctrl + D[= 后出现在右上角的按钮16=]。第二个让你 select 出现关于大小写,这样你可以分两步替换文本,首先 Plan 然后 plan.

快捷键是 Alt + C 区分大小写。 VS Code 的右上角会出现一个小工具栏,可让您切换搜索选项。

或者您只是 Ctrl + F 切换替换模式。

在 1.37(2019 年 7 月)中,可以通过 find/replace(现在可以通过保留大小写来替换)。

来自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.

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

9 月初的 v1.38 版本将 Preserve Case 功能扩展到使用 搜索面板 跨文件搜索时的替换。参见 add Preserve Case to Searches (all files)

.

There is also a new case preservation mode for hyphen-separated words.

v1.39 is adding preserve case for _underscore separated words. Like foo_bar.

https://github.com/microsoft/vscode/pull/79660

如果您想在不使用 find/replace 菜单的情况下实现此目的,可以使用一个扩展来解决您的问题:https://marketplace.visualstudio.com/items?itemName=Cardinal90.multi-cursor-case-preserve

所以 select 代码位,ctrl+h 打开替换,编辑查找和替换,在查找中关闭匹配大小写,在替换中打开保留大小写,Alt+L 查找 selection,然后Ctrl+Alt+Enter执行。

9/10 的情况下你会弄错,不值得付出努力。只需使用 ctr+d,然后对大写字母执行相同的操作。

个人期待通过ctrl+d的方式simpler/safer解决。 :)