VS Code#
Visual studio code is a highly customizable tool. This page covers the most common settings.
Settings#
You can configure your VSCode with editing the settings.json
file. There are separate settings.json
for user and for workspace.
Look for settings.json
in ./.vscode
folder for workspace.
Check information on the settiongs.json
for the user here. For linux, it’s typically in ~/.config/Code/User/settings.json
.
My typical config is:
{
"workbench.colorTheme": "Default Light Modern",
"window.zoomLevel": -2.5,
"editor.lineNumbers": "relative",
"python.analysis.typeCheckingMode": "strict",
}
Check Default VSCode settings. VSCode extensions usually have their own settings.
Debug#
Check:
The configuration file, .vscode/lanch.json
determines the behaviour of the vscode when debugging.
It’s typical structure is:
{
"version": "0.2.0",
"configurations": [
{
"name": "configuraiton1"
},
{
"name": "configuration2"
}
]
}
Under the “configuration” key, you can list a set of configurations, each of which represents a different debugging process.
The most basic debug configuration for python is:
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
Module#
Use the “module” option to debug a program that starts as as a module.
For me, a typical case is checking the logic of code specified in a unit test. If the unittest
framework is used, you should run the tests with the command python3 -m unittest
. The following configuration is suppose to use the debuger for the current file run with the unittest
framework.
{
"name": "Unittest: Current File",
"type": "debugpy",
"request": "launch",
"module": "unittest",
"args": "${file}",
"console": "integratedTerminal"
}
vim#
The Vim extension allows you to use vim-like navigation and command system inside VS Code. This section provides useful tips for using vim.
Search and replace#
To search in vim just type /<symbols combo to search>
. As you type, it will move you to the first occurrence below the cursor. It will also highlight all other instances of the search pattern. After pressing Enter
, the cursor will move to the closest match below. You can move to the next match by pressing n
and to the previous match by pressing N
.
To replace values in vim, you have to use a command like:
:<scope>\<value to be replaced>\<value to replace>\<parameters>
The most usefull command are represented in the following table:
Command |
Description |
---|---|
|
Replace first occurrence of |
|
Replace all occurrences of |
|
Replace first occurrence of |
|
Replace all occurrences of |
|
Same as above, but ask for confirmation before each change |
|
Replace |
|
Replace |
|
Replace whole word |
|
Replace |
|
Also case-insensitive (with |
|
Use very magic mode (fewer escapes needed in pattern) |
Use backslash symbol to escape a symbol in a pattern. For example, to replace the pattern /test
with hello
, use the command:
:s/\/test/hello/
To escape a backslash itlself, use the \\
combination before it. So, to replace the pattern \$
with $
:
:s/\\\$/$/