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
code --install-extension bierner.markdown-emoji
code --install-extension bierner.markdown-preview-github-styles
code --install-extension CoenraadS.bracket-pair-colorizer
code --install-extension eamodio.gitlens
code --install-extension formulahendry.auto-close-tag
code --install-extension himanoa.Python-autopep8
code --install-extension James-Yu.latex-workshop
code --install-extension lextudio.restructuredtext
code --install-extension mdickin.markdown-shortcuts
code --install-extension mhutchie.git-graph
code --install-extension mrmlnc.vscode-apache
code --install-extension ms-azuretools.vscode-docker
code --install-extension ms-mssql.mssql
code --install-extension ms-python.python
code --install-extension ms-vscode-remote.remote-containers
code --install-extension ms-vscode-remote.remote-ssh
code --install-extension ms-vscode-remote.remote-ssh-edit
code --install-extension ms-vscode-remote.remote-wsl
code --install-extension ms-vscode-remote.vscode-remote-extensionpack
code --install-extension Perkovec.emoji
code --install-extension ritwickdey.live-sass
code --install-extension ritwickdey.LiveServer
code --install-extension ronnidc.nunjucks
code --install-extension SolarLiner.linux-themes
code --install-extension streetsidesoftware.code-spell-checker
code --install-extension yzhang.markdown-all-in-one
code --install-extension zxh404.vscode-proto3

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 .

  1. Download Fira Code Font.
  2. Extract and then install the font after that.
    {
     "editor.fontFamily": "'Fira Code', 'Consolas', 'Courier New', monospace",
     "editor.fontLigatures": true
    }
    
  3. 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)
  • Replace **Course 1** by Course 1:
    • Find: \*\*Course (.*)\*\*
    • Replace: Course $1

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.

  1. Install extension Remote - SSH
  2. View > Command Palette… > type “SSH” and choose “Remote-SSH: Connect to Host…” > choose “+ Add New SSH Host…
  3. Type ssh user@host > Enter > choose a file to be updated, e.g. ~/.ssh/config.
  4. Click Connect if there is any popup in VSC.
  5. 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.