Reputation: 621
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?
Upvotes: 26
Views: 11430
Reputation: 13933
You can make a selection of code you want to debug and press SHIFT + ENTER
Upvotes: 0
Reputation: 2537
For those using MacOS:
Top right icon to open keybindings.json
:
And then paste something like this:
// Place your key bindings in this file to override the defaults
[
{
"key": "cmd+shift+enter",
"command": "editor.debug.action.selectionToRepl"
}
]
Upvotes: 0
Reputation: 24581
In recent versions of VSCode, you can do it from the user interface.
Go to Settings, then Keyboard Shortcuts (or go there directly with CTRL+K,CTRL+,), then search for "Evaluate in Debug Console".
Upvotes: 7
Reputation: 933
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.
Upvotes: 26
Reputation: 16000
You can use "Jump to Cursor" and that will cause the debugger to jump to that line next for execution; think of it as a GOTO statement. It's not the same as highlighting the code and sending it to the Debug Console, but should get you a similar result.
Upvotes: 2