Visual Studio Code extensions and adjustments
Visual Studio Code extensions¶
Extenstions are a purely subjective matter. Still some ideas might come from this for anybody reading this.
frame-indent-rainbow: frame-indent-rainbow - Visual Studio Marketplace
A plugin to show code blocks by color
OCP-CAD Viewer: OCP CAD Viewer - Visual Studio Marketplace
Pylance: Pylance - Visual Studio Marketplace
Visual Studio Code adjustments¶
Helpfull shortcuts¶
Visual studio Code Snippets¶
You can make/enter your own code Snippets which then can be called without typing everything again.
In the menue select: File -->Preferences --> Configure User Snippets
Then select the language you want to use your snippet for.
The following will allow you to type b123 and have a template ready.
{
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Build123d Header":{
"prefix": "b123",
"body": [
"from build123d import *",
"from ocp_vscode import *",
"set_defaults(reset_camera=Camera.KEEP, black_edges=True,center_grid=True)",
"$0",
"Final.part.export_stl(\"d:\\\\\\TestOut.stl\")",
"show_all()",
"#show_object()"
],
"description": "Shoortcut/Snippet to create build123 header/base template"
}
}
Adjust Keybinding¶
Type CTR+K and S
Search for: "Python: Run Python File in Terminal"
Set the Keybinding to run python with a shortcut.
First by selecting and right clicking select the "Change When Expression" column.
Change the when expression to:
editorTextFocus && !findInputFocussed && editorLangId == 'python'
Change the Keybinding (for example SHIFT+ENTER).
Adjust the Keybinding for SHIFT+ENTER for "Python: Run Selection/Line in Python Terminal" to ALT+ENTER or something different.
Coding Shortcuts:¶
mark block | STRG+SHIFT+ArrowDown |
---|---|
mark whole word | STRG+SHIFT+ArrowRight |
duplicate | STRG+D |
autocomplete suggestions | CTRL+SPACE |
search | STRG+F |
GLOBAL search | STRG+SHIFT+F |
Search and replace | STRG+H |
search for files | STRG+P |
Insert line above current line | CTRL+SHIFT+ENTER |
Insert line under current line | SHIFT+ENTER |
Change selected lines to comments | CTRL+# |
Debuger | |
Use debuger | F5 |
Set breakpoint | F9 |
jump to function definition | F12 |
rename function in whole code | F2 |
Debuger:
A debug toolbar appears along the top with the following commands from left to right: continue (F5), step over (F10), step into (F11), step out (Shift+F11), restart (Ctrl+Shift+F5), and stop (Shift+F5).
Link: Get Started Tutorial for Python in Visual Studio Code
CTRL+Shift+X: Open extensions view
Shift+Enter: Run selected lines