VS Code 与 Insiders 双版本共存:远程开发和本地工作的配置拆分
我在 macOS + Windows 两台本地电脑之外,还有一台通过 SSH 连接的 Linux 远程机器,平时有不少 Python / Jupyter / LaTeX 任务,用到 Remote-SSH、Copilot、GitLens 等扩展。我同时装了 VS Code 稳定版和 Insiders,各管一摊,分别配两套配置:
- VS Code 稳定版:主要负责 Remote-SSH 远程开发,连接高延迟的远程 Linux 机器,以“可预期、少变动”为优先,不容易因为某次自动更新导致远程开发突然出问题。
- VS Code Insiders:主要负责本地开发、本地工具集成和 LaTeX 写作,连接本机或局域网设备;新特性和新扩展先在 Insiders 上试水,稳定后再同步到远程那边。
这不是“最佳实践”,只是目前比较顺手的一种分工。
背景:环境和使用场景
- 远程服务器:Linux Mint 系统,CPU / 内存都不紧张,网络 RTT ≈ 200ms,不算小。
- 本地设备:macOS + Windows 各一台,性能都够用,本机开发、调试、文稿写作都在这里。
- 常用扩展:Remote-SSH、Python / Jupyter、Git / GitLens / GitHub Copilot、LaTeX Workshop,以及 draw.io 等本地工具。
远程开发要稳定可控(不因自动更新、扩展行为破坏远端环境),本地可以适当放开一些“重”功能,同时两套配置在多端的表现基本一致,切换电脑不会有明显差异。
远程开发配置:面向高延迟远程机器的 VS Code 设置
这一部分给 VS Code 稳定版用,目标是在 RTT ≈ 200ms 的情况下把交互往返次数尽量压低,同时充分利用远程机器的算力。
Remote-SSH 相关
{
"remote.SSH.remotePlatform": {
"tailscale": "linux",
"zerotier": "linux"
},
"remote.SSH.useLocalServer": true
}
remote.SSH.remotePlatform 显式把这些主机视为 Linux,避免平台误判;remote.SSH.useLocalServer: true 让一些操作通过本地 VS Code server 中转,减少频繁的 SSH 往返,在 200ms 延迟下更顺滑,如果后面发现不稳定再关掉。
文件监视与搜索
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/build/**": true,
"**/dist/**": true,
"**/__pycache__/**": true,
"**/.venv/**": true,
"**/data/**": true,
"**/large_generated/**": true,
"**/.mypy_cache/**": true,
"**/.pytest_cache/**": true,
"**/.ruff_cache/**": true
},
"search.exclude": {
"**/node_modules/**": true,
"**/build/**": true,
"**/dist/**": true,
"**/__pycache__/**": true,
"**/.venv/**": true,
"**/data/**": true,
"**/large_generated/**": true,
"**/.mypy_cache/**": true,
"**/.pytest_cache/**": true,
"**/.ruff_cache/**": true
}
}
这些目录要么是缓存(__pycache__、.mypy_cache 等),要么是构建产物(build / dist),要么是大量但不常直接编辑的数据集(data)。从监视和搜索里排除后,远程文件变更事件的传输和 Index / 搜索的负担都会小很多。
Python / Jupyter
远程机器计算资源够用,所以让远端语言服务多干活:
{
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.analysis.typeCheckingMode": "basic",
"python.analysis.indexing": true,
"python.analysis.diagnosticMode": "workspace",
"python.analysis.autoImportCompletions": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"jupyter.notebookFileRoot": "${workspaceFolder}",
"notebook.output.textLineLimit": 5000
}
indexing: true + diagnosticMode: "workspace" 让 LS 对整个项目索引和诊断,补全和跳转更完整,代价是初次加载和大规模变更时 CPU 会忙一阵;autoImportCompletions: true 让提示里带自动导入;notebook.output.textLineLimit 避免某个 cell 输出太多文本把前端卡死。如果证明确实太重,可以把这几个选项关回去。
终端与更新策略
{
"terminal.integrated.gpuAcceleration": "on",
"terminal.integrated.profiles.osx": {
"zsh-login": {
"path": "zsh",
"args": ["-l"]
}
},
"terminal.integrated.defaultProfile.osx": "zsh-login",
"terminal.integrated.automationProfile.osx": {
"path": "zsh",
"args": ["-l"]
}
}
终端配成 login shell 是为了在 macOS 上正确继承 PATH 和环境变量。
{
"update.mode": "manual",
"extensions.autoUpdate": false
}
这两条对应远程开发环境的要求:更新由我手动触发,不要被“某天早上的自动更新”打断。
编辑体验与 Git / 扩展
{
"editor.fontFamily": "Maple Mono CN, 'Fira Code', monospace",
"editor.fontLigatures": true,
"files.eol": "\n",
"window.title": "${activeEditorLong}${separator}${rootName}",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.autoSave": "onFocusChange",
"workbench.list.openMode": "doubleClick",
"workbench.editor.enablePreview": false,
"workbench.colorTheme": "GitHub Dark"
}
{
"git.autorefresh": false,
"diffEditor.ignoreTrimWhitespace": false,
"scm.diffDecorations": "gutter",
"git.confirmSync": false,
"github.copilot.nextEditSuggestions.enabled": true,
"gitlens.ai.model": "vscode",
"gitlens.ai.vscode.model": "copilot:gpt-4.1",
"gitlens.codeLens.enabled": false,
"gitlens.currentLine.enabled": false,
"gitlens.hovers.enabled": false
}
高延迟环境下关闭 git.autorefresh,避免后台频繁触发远程 Git 操作;GitLens 只保留必要功能,减少 UI 干扰;Copilot 开启“下一步建议”这类不那么激进的模式。
敏感信息:API Key 改用环境变量
一开始我把 Notebook 翻译扩展的 API key 明文写在 settings.json 里,后来意识到这是个明显错误,改成:
{
"ipynbTranslator.openai.apiKey": "${env:IPYNB_TRANSLATOR_OPENAI_API_KEY}",
"ipynbTranslator.openai.baseUrl": "https://api.chatanywhere.org/v1",
"ipynbTranslator.openai.model": "gpt-5-mini",
"ipynbTranslator.engine": "openai"
}
配合 shell 中的:
export IPYNB_TRANSLATOR_OPENAI_API_KEY="你的真实 key"
至少不会再把 key 明文写在配置文件里。
本地 / VS Code Insiders 配置:面向本机的“重度工作台”
Insiders 这边主要做本机/局域网内开发调试,以及 LaTeX 写作与 PDF 工具集成。本机性能相对宽裕,这套配置里更愿意开启一些检查和工具。
文件监视与终端
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true,
"**/__pycache__/**": true,
"**/.venv/**": true,
"**/build/**": true,
"**/dist/**": true,
"**/data/**": true,
"**/*.aux": true,
"**/*.log": true,
"**/*.synctex.gz": true,
"**/*.bbl": true,
"**/*.blg": true,
"**/*.fdb_latexmk": true,
"**/*.fls": true,
"**/*.toc": true,
"**/.mypy_cache/**": true,
"**/.pytest_cache/**": true,
"**/.ruff_cache/**": true
},
"terminal.integrated.defaultProfile.windows": "PowerShell"
}
和远程版相比多了 LaTeX 中间文件的排除,减少大型文档项目的监视负担。
Python 格式化与 Lint
Insiders 保留了一套 “Black + Flake8” 组合:
{
"editor.formatOnSave": true,
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"120"
],
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--max-line-length=120",
"--ignore=E203,W503"
],
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"python.analysis.typeCheckingMode": "basic"
}
没有专门为 Insiders 调到 strict,一是出于习惯,二是避免在复杂项目里报出过多“噪音”式的警告。
统一编辑器体验
{
"editor.fontFamily": "Maple Mono Normal NF CN, 'Fira Code', monospace",
"editor.fontLigatures": true,
"files.eol": "\n",
"editor.detectIndentation": true,
"window.title": "${activeEditorLong}${separator}${rootName}",
"editor.minimap.enabled": true,
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.autoSave": "onFocusChange"
}
目标是两套 VS Code 在表现层面尽量一致,不因切换版本产生明显割裂感;少量差别(如 minimap 开启)是“本机更强,可以多开一点东西”。
Git / GitLens 与 Remote-SSH
{
"[git-commit]": {
"editor.rulers": [72]
},
"git.confirmSync": false,
"remote.SSH.remotePlatform": {
"remote-linux": "linux"
},
"terminal.integrated.tabs.enabled": false,
"gitlens.ai.model": "vscode",
"gitlens.ai.vscode.model": "copilot:gpt-4.1"
}
这一块和远程版思路类似,只是这里的 Remote-SSH 多用在局域网或本机互连场景,延迟不再是最大问题。
LaTeX Workshop:同时兼顾 macOS 与 Windows
Insiders 还承担 LaTeX 写作,这部分配置相对完整。编译链:
{
"latex-workshop.latex.autoBuild.run": "onSave",
"latex-workshop.latex.recipes": [
{
"name": "xelatex ×2(日常最干净)",
"tools": ["xelatex", "xelatex"]
},
{
"name": "xelatex → bibtex → xelatex×2(加文献时切换)",
"tools": ["xelatex", "bibtex", "xelatex", "xelatex"]
}
],
"latex-workshop.latex.recipe.default": "xelatex ×2(日常最干净)",
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "bibtex",
"command": "bibtex",
"args": ["%DOCFILE%"]
}
]
}
macOS 上使用 Skim:
{
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"latex-workshop.view.pdf.external.viewer.args": [
"0",
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"latex-workshop.view.pdf.external.synctex.args": [
"-r",
"-b",
"%LINE%",
"%PDF%",
"%TEX%"
],
"latex-workshop.synctex.afterBuild.enabled": true
}
Windows 上使用 SumatraPDF 的配置放在多行注释里,需要时再启用:
/*
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
"-reuse-instance",
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"%PDF%"
],
"latex-workshop.synctex.afterBuild.enabled": true,
*/
另外关掉了 LaTeX Workshop 的弹窗消息:
{
"latex-workshop.formatting.latex": null,
"latex-workshop.message.error.show": false,
"latex-workshop.message.warning.show": false,
"latex-workshop.message.badbox.show": false
}
错误和警告仍会出现在 Problems 面板里,自己看即可。
排错记录
- 多端共享 settings 的路径问题:在 Windows 上同步到含 macOS 路径的配置(如
/Applications/Skim.app/...)时,VS Code 对不适用当前 OS 的路径常常“无感忽略”,但维护上不清爽。目前用多行注释区分 macOS / Windows 段,启用时按当前平台手动切换。 remotePlatform写错主机名:主机名写错或不匹配时,VS Code 可能错误推断远程平台类型,导致某些功能表现异常或安装扩展不准确。Remote-SSH 配置里只写真正常用的主机,用明确、稳定的标识(如 IP 或固定别名)。- 自动更新影响远程环境:早先允许扩展自动更新时,出现过几次远程环境“昨天还好好的”,第二天某个扩展更新后出现兼容性问题。远程这套因此改为
update.mode = manual+extensions.autoUpdate = false,本地 Insiders 也倾向于手动确认更新。
两套配置分开后,远程环境不再被自动更新和后台刷新打断,本地可以放心试新东西。