Thursday, April 28, 2022

Sending code to debug console in Visual Studio for Python

 Similar to this advice I found on stackoverflow, I did the following to be able keyboard debug my Python code:

File > Preferences > Keyboard Shortcuts

Then in the top right there is an icon to Open Keyboard Shortcuts (JSON), in there I put:

[
    {
        "key": "shift+c",
        "command": "editor.debug.action.selectionToRepl"
    }
]

BOOM!  Now I can highlight my code, and hit Shift+c to send the snippet to the debug console.  

NOTE: I used Shift+c as it is similar to C-c C-c in Emacs, and C-c is taken in Windows for Copy.


EDIT:  Oops, I can't use capital C with this, so instead I am now using Ctrl+alt+enter

// Place your key bindings in this file to override the defaults
[
    {
        "key": "ctrl+alt+enter",
        "command": "editor.debug.action.selectionToRepl"
    }
]

No comments:

Post a Comment