Last modified on 01 Oct 2021.
Install
Download and install here.
Extensions
# list the installed extensions
# unix
code --list-extensions | xargs -L 1 echo code --install-extension
# windows
code --list-extensions | % { "code --install-extension $_" }
# To re-install on a new machine
# just copy-paste the results and run on terminal
reStructuredText
preview engine sphinx is not installed
=> in Ubuntu 20.04+
sudo apt install python-is-python3
# prevent Python 2 from being installed as a dependency of something
sudo apt-mark hold python2 python2-minimal python2.7 python2.7-minimal libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib
Add extra path to auto complete
Open settings.json
and add,
{
"python.autoComplete.extraPaths": [
"C:\\Users\\dinha\\Documents\\GitHub\\dataswati\\python-dataswati"
],
}
Fix Pylint unable to import
Open settings.json
and add,
"python.linting.pylintArgs": [
"--init-hook",
"import sys; sys.path.append('C:\\Users\\dinha\\Documents\\GitHub\\dataswati\\python-dataswati')"
]
Appearances
Change font for internal terminal
Make a good corresponding to zsh.
# Open settings JSON
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.fontFamily": "Source Code Pro Medium",
"terminal.integrated.fontSize": 15
Enable font ligatures
👉 Reference.
For example, you type = + >, it becomes ⇒
.
- Download Fira Code Font.
- Extract and then install the font after that.
{ "editor.fontFamily": "'Fira Code', 'Consolas', 'Courier New', monospace", "editor.fontLigatures": true }
- Reload VSC.
💡 If you only wanna apply this setting for some file format, you can click on the language at the bottom right of VSC, then click Configure ‘Markdown’ language based setting.
Regular Expression
- Using regular expression in Visual Studio (Code) ⇾ ref
- Replace current bit.ly text with its same url:
- Find:
(http://bit.ly.*)
(Enable.*
) - Replace:
[$1]($1)
- Find:
- Replace
**Course 1**
byCourse 1
:- Find:
\*\*Course (.*)\*\*
- Replace:
Course $1
- Find:
Exlude files/folders in file search Visual Studio Code (VSC)
Go to Preferences > Settings > search exclude
and modify inside section Search: Exclude
. More patterns can be found here.
Below is an example list,
**/node_modules
**/bower_components
**/*.code-search
**/_site
**/.jekyll-cache
**/.sass-cache
**/*.ico
**/*.png
**/*.ipynb
**/*.jpg
**/*.jpeg
**/*.svg
Connect ssh
folders in VSC
Read this tutorial.
- Install extension Remote - SSH
- View > Command Palette… > type “SSH” and choose “Remote-SSH: Connect to Host…” > choose “+ Add New SSH Host…”
- Type
ssh user@host
> Enter > choose a file to be updated, e.g.~/.ssh/config
. - Click Connect if there is any popup in VSC.
- Choose platform on the server, usually Linux.
Error?
# Could not establish connection to "undefined". Could not resolve hostname.
# ref: https://github.com/microsoft/vscode-remote-release/issues/1047
# Open config ssh file
# Ctrl+Shift+P then "Remote-SSH: Open Configuration File"
# In stead of
Host XXX.XXX.XXX.XXX
User bob
Port 22
IdentityFile ~/.ssh/id
# use this
Host server_name # Do not put ip here
HostName XXX.XXX.XXX.XXX # But put it here
User bob
Port 22
IdentityFile ~/.ssh/id
# Then Ctrl+Shift+P > "Remote-SSH: Connect to host"
# Pick "server_name"
Settings
👉 Check this file.
Use settings for a custom file extension,
# the list of extension name will be showed when typing
"[markdown]": {
"editor.tabSize": 4,
},
"[restructuredtext]": {
"editor.wordWrap": "on",
}
Pylint
# _Unable to import_ some user-defined package
# 1. Make sure the right env running in vscode
# For example, popai (conda)
# 2. Make a symblic link
ln -s /home/thi/git/dataswati/python-dataswati/popai /home/thi/miniconda3/envs/popai/lib/python3.8/popai
# unresolved import
# Ctrl + Shift + P
# Preferences: Open Workspace Settings (JSON)
"settings": {
"python.pythonPath": "/usr/bin/python3",
"python.autoComplete.extraPaths": [
"/usr/lib/python3/dist-packages",
"/app/src/python/"
# or other paths you want!
]
}
Hot keys
One can change the default keyboard shortcut by going to: File > Preferences > Keyboard Shortcuts.
- Quick search file: Ctrl + P.
- Get back to previous views: Ctrl + Alt + - (Linux), Alt + < (Windows), Ctrl + - (MacOS).
- Get forward: Ctrl + Shift + - (Linux), Alt + > (Windows), Ctrl + Shift + - (MacOS).
- Open Command Palette: Ctrl + Shift + P.
- Forat on save: Ctrl + Shift + I.
- Go to line: Ctrl + Shift + P then Go to line.