我在keybindings.json中做了一些修改:
{
"key": "cmd+enter",
"command": "editor.action.insertLine", // this doesn't work, command not found
"when": "editorTextFocus"
},
{
"key": "enter",
"command": "editor.action.insertLineAfter", // to insert line below, this works correctly
"when": "editorTextFocus"
}我的想法是防止出现以下情况:
print("sentence~") # here I am pushing "Enter" while cursor is in ~ place
print("sentence
")现在,在更改之后,虽然光标在")之前,但它在按下"Enter“后跳到新行,这是预期的(90%的使用)。
我现在的问题是,前面的命令(在按下“Enter”之后)不再存在。因此,我无法将中间的行减半(占使用率的10%),并在光标之后再转到新行和前一行的其余部分。
我正在寻找一个命令,我可以钉到"Cmd + Enter“。我以为可能只是"editor.action.insertLine“,但这是不正确的。
谢谢你的帮助,塞司
发布于 2022-08-11 13:39:31
似乎您可以利用“插入代码段”命令特性来调用由单行分隔符(\n)组成的代码段:
"command": "editor.action.insertSnippet",
"args": { "snippet": "\n" }`谢谢:Visual Studio Code snippet as keyboard shortcut key
使用…尝试类似于您的需求
{
"key": "enter",
"command": "editor.action.insertLineAfter",
"when": "editorTextFocus && !suggestWidgetVisible"
},
{
"key": "ctrl+enter",
"command": "editor.action.insertSnippet",
"args": { "snippet": "\n" },
"when": "editorTextFocus && !suggestWidgetVisible"
},
{
"key": "shift+enter",
"command": "editor.action.insertLineBefore",
"when": "editorTextFocus && !suggestWidgetVisible"
},…而且它似乎在Windows上正常工作。(我添加了更多限制性的"when“规则,以便仍然能够确认建议。)
发布于 2022-08-11 12:44:33
>>打开键盘快捷键
https://stackoverflow.com/questions/73320759
复制相似问题