有没有办法在 VS Code 中通过方法名称启用驼峰驼峰?

问题描述 投票:0回答:5

由于这个问题是针对“大”Visual Studio 和 Resharper,我也希望在 VS Code 中看到该功能。

滚动浏览 VS Code 的快捷方式列表,我找不到它,但我希望它仍然存在,但被称为比 camelhump 等不太直观的东西。

keyboard-shortcuts visual-studio-code camelcasing
5个回答
87
投票

从版本 1.25 开始,这些命令是内置的:

enter image description here


5
投票

我发现这个扩展可以工作https://marketplace.visualstudio.com/items?itemName=ow.vscode-subword-navigation

有趣的是,您需要单独配置每个组合:

{
    "key": "alt+left",
    "command": "subwordNavigation.cursorSubwordLeft",
    "when": "editorTextFocus"
},
{
    "key": "alt+right",
    "command": "subwordNavigation.cursorSubwordRight",
    "when": "editorTextFocus"
},
{
    "key": "alt+shift+left",
    "command": "subwordNavigation.cursorSubwordLeftSelect",
    "when": "editorTextFocus"
},
{
    "key": "alt+shift+right",
    "command": "subwordNavigation.cursorSubwordRightSelect",
    "when": "editorTextFocus"
},
{
    "key": "alt+backspace",
    "command": "subwordNavigation.deleteSubwordLeft",
    "when": "editorTextFocus"
},
{
    "key": "alt+delete",
    "command": "subwordNavigation.deleteSubwordRight",
    "when": "editorTextFocus"
}

5
投票

如果由于某些原因你的绑定没有设置,这里是获取 Cezn 快捷方式的 JSON。

{
    "key": "ctrl+alt+right",
    "command": "cursorWordPartRight",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+shift+right",
    "command": "cursorWordPartRightSelection",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+left",
    "command": "cursorWordPartLeft",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+shift+left",
    "command": "cursorWordPartLeftSelection",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+alt+backspace",
    "command": "deleteWordPartLeft",
    "when": "editorTextFocus && !editorReadonly"
},
{
    "key": "ctrl+alt+delete",
    "command": "deleteWordPartRight",
    "when": "editorTextFocus && !editorReadonly"
}

请小心使用 ctrl+alt+delete,因为它与另一种流行的 Windows 快捷方式冲突。

其他有趣的绑定是:

{
    "key": "ctrl+n",
    "command": "explorer.newFile",
    "when": "explorerViewletFocus"
},
{
    "key": "ctrl+shift+n",
    "command": "explorer.newFolder",
    "when": "explorerViewletFocus"
}

1
投票

为此有一个扩展:Camel Case Navigation

enter image description here


0
投票

调整了这个答案,使其适用于 v1.91

{
    "key": "alt+right",
    "command": "cursorWordPartRight",
    "when": "editorTextFocus"
},
{
    "key": "alt+shift+right",
    "command": "cursorWordPartRightSelect",
    "when": "editorTextFocus"
},
{
    "key": "alt+left",
    "command": "cursorWordPartLeft",
    "when": "editorTextFocus"
},
{
    "key": "alt+shift+left",
    "command": "cursorWordPartLeftSelect",
    "when": "editorTextFocus"
},
{
    "key": "alt+backspace",
    "command": "deleteWordPartLeft",
    "when": "editorTextFocus && !editorReadonly"
},
{
    "key": "alt+delete",
    "command": "deleteWordPartRight",
    "when": "editorTextFocus && !editorReadonly"
}
© www.soinside.com 2019 - 2024. All rights reserved.