VS Code execute current line or selection to in the integrated console

扶醉桌前 提交于 2019-12-03 13:37:58
user6273920

Actually, I found that adding VSCode Macros extension does the job:

I just changed settings.json:

{
    "window.zoomLevel": 1,
    "editor.fontSize": 11,
    "terminal.integrated.fontSize": 11,
    "macros": {
        "execCurLn": [
            "expandLineSelection",
            "workbench.action.terminal.runSelectedText",
            "cancelSelection"
        ]
    }
}

and added (1st part is pure @kwood & thank u again) to keybindings.json

   {
        "key": "ctrl+enter",
          "command": "workbench.action.terminal.runSelectedText",
            "when": "editorTextFocus && editorHasSelection"
    }
    {
        "key": "ctrl+enter",
          "command": "macros.execCurLn",
            "when": "editorTextFocus && !editorHasSelection"
    },
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
{ "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}

If you already have your terminal and REPL open, there is a built in command called "Run Selected Text in Active Terminal" / workbench.action.terminal.runSelectedText.

It has no default keybinding, so you need to set it yourself. Something like this would work:

{
  "key": "ctrl+enter",
  "command": "workbench.action.terminal.runSelectedText",
  "when": "editorTextFocus && editorHasSelection"
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!