在Python交互窗口VSCode中交换shift-enter和回车

2024-04-02

In the interactive window in vscode you press shift-enter to run the code you just typed and enter to go to the next line. Can I swap this? enter image description here


当前的答案解释了如何让“enter”执行命令,但他们没有给你另一半:让shift+enter插入一个新行。这是完整的解决方案(我从类似问题的各种答案中汇总了多个解决方案,以感谢其他提供帮助的人)。额外奖励:我来自 MATLAB,所以我还在 ipython 窗口中使用“F9”执行选择。

打开keybindings.json(ctrl+shift+p,打开键盘快捷键(JSON) 添加以下内容:

    [
    {
        "key": "enter",
        "command": "interactive.execute",
        "when": "!suggestWidgetVisible && resourceScheme == 'vscode-interactive'"
    },
    {
        "key": "shift+enter",
        "command": "",
        "when": "!suggestWidgetVisible && resourceScheme == 'vscode-interactive'"
    },
    {
        "key": "f9",
        "command": "jupyter.execSelectionInteractive",
        "when": "editorTextFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'python'"
    }
]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在Python交互窗口VSCode中交换shift-enter和回车 的相关文章

随机推荐