pythondebuggingkeyboard-shortcutsvisual-studio-code

Is there a shortcut in VSCode to execute current line or selection in debug REPL?


I am developing with Python and commonly running code in an integrated terminal with Shift + Enter. However, when debugging the process seems to be more complicated. I need to copy the code, move focus to debug REPL (Ctrl + Shift + Y), paste, run and move focus back to the editor. Is there any easier way to do this?


Solution

  • If you use the vscode's integrated debugging you can set a shortcut for sending selection to debug Repl. I use this on my keybindings.json config file:

    {
        "key": "shift+alt+d",
        "command": "editor.debug.action.selectionToRepl"
    }
    

    The difference from the "workbench.action.terminal.runSelectedText" command is that you actually have to select the line to send to the debug Repl, does not work for just putting the cursor on the line and hitting the shortcut.