How to run the select code in VScode?
@yanachen, this is now possible in VS Code. All you need to do is:
1. Ensure python is running in the VS Code terminal window
2. Select the text you wish to execute in python
3. Invoke the command 'workbench.action.terminal.runSelectedText' as defined in the following link:
https://code.visualstudio.com/docs/editor/integrated-terminal#_key-bindings
Now it's supported by default shortcut "shift" + "enter".
- select the proper code snippet
- press "shift" + "enter"
There is no default keybindings for command "Run Selected Text in Active Terminal", but you can create one.
- Press Ctrl+K, Ctrl+S to open File → Preferences → Keyboard Shortcuts.
- Search for
workbench.action.terminal.runSelectedText
in keybindings. - Press the icon on the left to open a windnow with this message "Press desired key combination..." and make your choice. (I've pressed Ctrl+Alt+R - as this combination was not used yet.)
- Press Enter to store your keybinding.
Tested on VSCode 1.30.2 on Windows 10 Pro.