‘VS code’ is a very useful and powerful source code editor for programmers and scientists. It has many configuration options for advanced users. However it is a bit difficulty to configure all these options because its options are edited rather than checked on buttons as normal windows applications. Here, I just share my configuration of VS code as a backup for easy use and reconfiguration after new installation.

Default setting

The setting of VS code is different from normal software which uses check options and menus. VScode use script to control the default settings. The configuration script file ‘settings.json’ is like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"python.pythonPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Anaconda3_64\\python.exe",
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"editor.minimap.enabled": false,
"editor.rulers": [
80,
120
],
"workbench.editor.untitled.hint": "hidden",
"editor.acceptSuggestionOnCommitCharacter": false,
"editor.acceptSuggestionOnEnter": "off",
"editor.snippetSuggestions": "none",
"editor.quickSuggestions": {
"other": false,
"comments": false,
"strings": false
}
}

Stop workspace trust check

Every time you opened a script file, VScode will ask your trust. To avoid this annoy thing, you can just change the default setting in VScode setting.json as:

1
2
#    "security.workspace.trust.untrustedFiles": "open",
"security.workspace.trust.untrustedFiles": "close",

Auto wrap long line

The setting method has been discussed in stackoverflow [https://stackoverflow.com/questions/38561881/how-do-i-turn-on-text-wrapping-by-default-in-vs-code], you can just open the: File -> preference -> setting and change the “editor.wordWrap”: “off” to “on”.

Add vertical width indication ruler at 80

You can also set custom the vertical ruler at 80 line length by change the settings.json [https://stackoverflow.com/questions/29968499/vertical-rulers-in-visual-studio-code]. You need to add a new line as “editor.rulers”: [80,120], and then save the .json file.

Turn on English spelling check

When I write markdown blog with VS code, I would like to turn on the British English spelling check for the markdown source code. This could also be easily realized in VS code by install the 3rd plugin: ‘Code Spell Checker’ [https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker]. And then make the configuration as: Code Spell Checker -> extension setting -> C Spell: Language, en-GB