认识
官网:https://code.visualstudio.com/
文档:https://code.visualstudio.com/docs
仓库:https://github.com/microsoft/vscode
VS Code is a free code editor, which runs on the macOS, Linux, and Windows operating systems. Getting up and running with Visual Studio Code is quick and easy. It is a small download so you can install in a matter of minutes and give VS Code a try. VS Code is lightweight and should run on most available hardware and platform versions. You can review the System Requirements to check if your computer configuration is supported. 简而言之,VS Code 是个扩展性极强的轻量级的代码编辑器。
组成
概念、术语
用户界面 User interface
https://code.visualstudio.com/docs/getstarted/userinterface
Activity Bar
Primary Side Bar
Secondary Side Bar
Command Palette
Editor
Panel
Status Bar
性质
快捷按键 | Shortcuts
Format Document (Ctrl+Shift+I) – Format the entire active file.
Format Selection (Ctrl+K Ctrl+F) – Format the selected text.
远程开发 | Remote
VS Code Remote Development | https://code.visualstudio.com/docs/remote/remote-overview
设置 SSH 连接的显示名称,~/.ssh/config Host 字段。
退出远程开发(visual studio code – How to get rid of vscode remote development?):
File > Close Remote Connection.
主题配色 | Theme Color
https://code.visualstudio.com/api/references/theme-color
针对 Workspace 的主题 vscode settings – Different theme per window in Visual Studio Code – Stack Overflow
Open the project folder where you would like to have a different color theme.
Navigate to File > Preferences > Settings.
Select the “Workspace Settings” tab at the top of the settings screen. Anything you edit in here will now be specific to this workspace.
Search for “colorTheme” and select the color theme you would like for this specific workspace.
提供终端窗口
Sticky Scroll
插件扩展 | Plugin | Extension
配置使用:https://code.visualstudio.com/docs/configure/extensions/extension-marketplace
Extension Marketplace | https://marketplace.visualstudio.com/VSCode
构建
安装
https://code.visualstudio.com/docs/setup/linux
通过 .tar.gz 安装
https://code.visualstudio.com/#alt-downloads
# 2025-11-19 我们从 Flatpak 切换到该方式,原因在于我们的 VS Code 环境需要与操作系统互相操作,并且我们不想在 Flatpak Sandbox 相关的问题上花费时间。
通过 apt/deb 安装
# 03/30/2019 VSCode on Debian 10.5
cd /tmp
curl -s https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" \
> /etc/apt/sources.list.d/vscode.list
apt-get update
apt-get install -y code # or code-insiders
通过 Flatpak 安装
# 05/16/2024
https://flathub.org/apps/com.visualstudio.code
flatpak install flathub com.visualstudio.code
flatpak run com.visualstudio.code
常用配置 | Flatpak 应用运行于沙箱之中,需要进行相关设置:
修改 Shell 配置,使其使用系统的 Shell 配置 | Use host shell in the integrated terminal.
...
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/app/bin/host-spawn",
"args": ["bash"],
"icon": "terminal-bash",
"overrideName": true
}
}
...
应用
编辑 Markdown 文件
Markdown All in One | by Yu Zhang
- 官网:https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
- 文档:https://github.com/yzhang-gh/vscode-markdown/blob/master/README.md
- 仓库:https://github.com/yzhang-gh/vscode-markdown
Office Viewer
- 仓库:https://github.com/cweijan/vscode-office
- 该插件使用 Vditor 来提供 Markdown 的图形化预览。https://github.com/Vanessa219/vditor
Mermaid —— Markdown Preview Mermaid Support – Visual Studio Marketplace
字体修改
https://stackoverflow.com/questions/57008558/how-to-change-the-font-of-visual-studio-codes-ui
Ubuntu 25.04 VS Code 1.104.1
- 修改界面字体:取决于操作系统字体设置,或者通过插件来修改字体。
- 修改插件字体:取决于插件是否提供配置选项
我们修改操作系统字体,进而简介修改 VS Code 字体。
Office
Edit csv – extension to edit csv files with a table ui
Office Viewer | by Database Client
JSON
YAML | YAML Language Support by Red Hat
redhat.vscode-yaml
https://github.com/redhat-developer/vscode-yaml
Unable to load schema from ‘
https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json’: connect ECONNREFUSED 0.0.0.0:443.
JSON CRACK
- https://jsoncrack.com/
- https://marketplace.visualstudio.com/items?itemName=AykutSarac.jsoncrack-vscode
- https://github.com/AykutSarac/jsoncrack-vscode
Git
GitLens – Git supercharged
显示谁修改当前行
禁用 Git 功能
File / Preferences / Settings / Extensions / Git / Enable
https://stackoverflow.com/questions/47948626/how-to-disable-source-control-providers-in-vscode
Database
连接 SQL Server 数据库
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-develop-use-vscode#connect-to-sql-server
Graphviz
Visual Studio Marketplace/Graphviz (dot) language support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=joaompinto.vscode-graphviz
Terraform
HashiCorp Terraform
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Python | 插件 | 常用配置 | ……
Sort Imports | Editing Python Code in Visual Studio Code
isort 模块,来实现 import 排序;
Right-click in editor and select
Sort Imports (no selection is required)
2)Command Palette (
Ctrl+Shift+P), then
Python Refactor: Sort Imports
改进
Unable to watch for file changes in this large workspace folder
Visual Studio Code User and Workspace Settings
Running Visual Studio Code on Linux ⇒ “Visual Studio Code is unable …
Unable to watch for file changes in this large workspace folder. Please follow the instructions link to resolve this issue.
原因分析
- 或,工作目录的文件过多,导致 VS Code File Watcher 的句柄用完,而无法检测全部文件的变更。
- 或,其他程序占用过多 file handle 而导致 VS Code 无法正常运行。
解决方案
或,配置 fs.inotify.max_user_watches=524288 参数,来增加允许文件句柄数。根据文档:
或,忽略不必要的文件:
# .vscode/settings.json
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**": false
}
}
参考
SqlToolsService Known Issues
Running VS Code on Linux/Installation
Visual Studio Code on Linux