我已经开始在MacOS上使用Visual Studio代码。
用 Alt + 左/右跳转确实很烦人,因为它跳了完整的标识符而不是一个单词。
示例:
我想要 Ctrl + 右可以完成上述操作,并修改 Alt + 右的行为,使其按单词跳转
我想要的行为:
解决方案:
我最后的keybindings.json
配置带有添加的 Shift (选择)选项:
[
{
"key": "alt+left",
"command": "cursorWordPartLeft",
"when": "editorTextFocus",
},
{
"key": "alt+right",
"command": "cursorWordPartRight",
"when": "editorTextFocus",
},
{
"key": "shift+alt+left",
"command": "cursorWordPartLeftSelect",
"when": "editorTextFocus"
},
{
"key": "shift+alt+right",
"command": "cursorWordPartRightSelect",
"when": "editorTextFocus"
},
{
"key": "ctrl+left",
"command": "cursorWordStartLeft",
"when": "editorTextFocus"
},
{
"key": "ctrl+right",
"command": "cursorWordEndRight",
"when": "editorTextFocus"
},
{
"key": "shift+ctrl+left",
"command": "cursorWordStartLeftSelect",
"when": "editorTextFocus"
},
{
"key": "shift+ctrl+right",
"command": "cursorWordEndRightSelect",
"when": "editorTextFocus"
},
]
答案 0 :(得分:1)
您正在寻找
cursorWordPartRight
与 Shift - Alt - Q 绑定的。
Alt -右已绑定到“ Go Forward
”命令,您可以删除该绑定并将其用于cursorWordPartRight
命令。
{
"key": "alt+right",
"command": "cursorWordPartRight",
"when": "editorTextFocus",
},
{
"key": "alt+left",
"command": "cursorWordPartLeft",
"when": "editorTextFocus",
}
它可能需要每种语言解析器都支持。它确实可以在JavaScript中工作。
cursorWordPartLeft (command exists but is unbound by default).
还有其他未绑定的相关命令:
cursorWordPartRightSelect
cursorWordPartLeftSelect
cursorWordPartStartLeft
cursorWordPartStartLeftSelect