前言

一位在读博士跟我说:他每天的科研工作横跨 6 个工具——Zotero 看文献、Word 写论文、MATLAB 跑实验、Overleaf 排版、有道翻译查词、微信传文件。每次切换都是一次上下文中断,严重影响深度工作状态。

其实,这一切都可以在 VS Code 里完成。本文手把手带你把 VS Code 改造成一套专为科研设计的沉浸式工作环境,从文献阅读到论文发表,一个窗口搞定。


一、整体架构

VS Code 学术工作流
├── 文献阅读       PDF Viewer + Continue AI 解读
├── 论文写作       Markdown + LaTeX 公式 + BibTeX 引用
├── AI 辅助        Continue + 本地 Ollama(Qwen3/Gemma4)
├── 实验记录       Jupyter Notebook(内置支持)
├── 版本管理       Git Source Control 面板
└── 文献管理       Zotero + Better BibTeX

二、核心插件安装(15 分钟完成)

打开 VS Code,按 Ctrl+Shift+X 进入扩展商店,搜索安装以下插件:

插件名 用途 重要程度
WSL 连接到 Ubuntu 环境 ⭐⭐⭐ 必装
Continue 接入本地 AI 模型 ⭐⭐⭐ 必装
Markdown All in One Markdown 增强(快捷键/目录/公式) ⭐⭐⭐ 必装
Markdown Preview Enhanced LaTeX 公式渲染 ⭐⭐⭐ 必装
PDF Viewer VS Code 内直接阅读 PDF ⭐⭐⭐ 必装
Pandoc Citer BibTeX 引用自动补全 ⭐⭐ 推荐
Word Count 实时字数统计 ⭐⭐ 推荐
Code Spell Checker 拼写检查(支持学术词典) ⭐⭐ 推荐

三、配置 Continue 接入本地模型

3.1 基础配置

安装 Continue 后,按 Ctrl+Shift+L 打开侧边栏,点击 ⚙️ 图标编辑配置文件 ~/.continue/config.json

{
  "models": [
    {
      "title": "Qwen3-8B(中文解读/翻译)",
      "provider": "ollama",
      "model": "qwen3:8b",
      "apiBase": "http://localhost:11434",
      "systemMessage": "你是一位专业的学术助手,专注于计算机科学和工程领域。解释时保留英文术语并附中文注释,回答简洁专业。"
    },
    {
      "title": "Gemma4-12B(英文润色)",
      "provider": "ollama",
      "model": "gemma4:12b",
      "apiBase": "http://localhost:11434",
      "systemMessage": "You are an academic English editor specializing in CS papers. Be precise and concise."
    }
  ],
  "slashCommands": [
    {
      "name": "proofread",
      "description": "学术润色",
      "prompt": "Proofread the following academic text. Fix grammar, tense, and style only. Return only the corrected text:\n\n{{{ input }}}"
    },
    {
      "name": "explain",
      "description": "中文解释",
      "prompt": "请用中文解释以下学术内容,保留英文术语并在括号内注释含义,语言简洁:\n\n{{{ input }}}"
    },
    {
      "name": "abstract",
      "description": "生成摘要",
      "prompt": "请用3-5句中文概括以下段落的核心贡献和主要结论:\n\n{{{ input }}}"
    }
  ]
}

3.2 实战案例:阅读论文时用 AI 实时解读

场景:阅读一篇关于 Diffusion Model 的论文,遇到这段难懂的数学描述:

The forward process gradually adds Gaussian noise to the data 
according to a variance schedule β₁,...,βT, such that 
q(x_t|x_{t-1}) = N(x_t; √(1-βt)x_{t-1}, βtI).

操作步骤
1. 在 PDF Viewer 中打开论文(VS Code 内直接双击 PDF 文件)
2. 用鼠标选中这段文字,复制
3. 切换到 .md 笔记文件,粘贴
4. 选中该段,按 Ctrl+Shift+L → 输入 /explain

AI 输出

前向过程(Forward Process)逐步向数据 x₀ 添加高斯噪声(Gaussian Noise)。

其中:
- β₁,...,βT 是方差调度表(Variance Schedule),控制每步添加噪声的强度
- q(x_t|x_{t-1}) 表示从第 t-1 步到第 t 步的条件概率
- √(1-βt)x_{t-1} 是均值,βtI 是方差
- 直觉理解:每一步都是对上一步的图像做轻微的模糊处理,经过 T 步后变成纯噪声

30 秒内理解了本需要查阅 3 篇辅助材料才能搞懂的公式。✅


四、Markdown 写论文工作流

4.1 文件结构规范

my_paper/
├── main.md              # 论文正文
├── references.bib       # BibTeX 参考文献库
├── figures/             # 图表
│   ├── fig1_framework.png
│   └── fig2_results.png
├── notes/               # 阅读笔记
│   ├── 2024_attention.md
│   └── 2024_diffusion.md
└── .vscode/
    └── settings.json    # 工作区配置

4.2 工作区配置(.vscode/settings.json

{
  "markdown.math.enabled": true,
  "editor.wordWrap": "on",
  "editor.lineHeight": 1.8,
  "cSpell.language": "en",
  "cSpell.userWords": ["GNN", "LSTM", "Transformer", "softmax", "backpropagation"],
  "pandoc-citer.rootFile": "main.md",
  "wordcount.activateToFileGlob": "**/*.md"
}

4.3 实战案例:BibTeX 引用自动补全

步骤一:在 references.bib 中添加(可从 Google Scholar 直接导出):

@inproceedings{vaswani2017attention,
  title={Attention is all you need},
  author={Vaswani, Ashish and others},
  booktitle={NeurIPS},
  year={2017}
}

步骤二:在 main.md 中写作时,输入 @ 自动弹出补全菜单:

The Transformer architecture [@vaswani2017attention] has become the 
dominant paradigm in sequence modeling tasks.

步骤三:用 Pandoc 生成带格式参考文献的 PDF:

sudo apt install pandoc texlive-xetex

pandoc main.md \
  --bibliography references.bib \
  --csl ieee.csl \
  --pdf-engine=xelatex \
  -o paper_draft.pdf

4.4 实战案例:LaTeX 公式实时预览

写公式时按 Ctrl+K V 打开预览面板,左侧写 Markdown,右侧实时渲染:

本文的目标函数定义如下:

$$
\mathcal{L}(\theta) = \mathbb{E}_{(s,a,r,s') \sim \mathcal{D}} 
\left[ \left( r + \gamma \max_{a'} Q_{\theta^-}(s', a') - Q_\theta(s, a) \right)^2 \right]
$$

其中 $\gamma \in (0,1]$ 为折扣因子,$\mathcal{D}$ 为经验回放缓冲区。

五、实验记录工作流

5.1 实战案例:在 VS Code 中记录一次完整实验

新建 experiments/exp_2025_05_26.ipynb,记录超参数、指标和结论:

# Cell 1:实验配置
config = {
    "model": "GraphSAGE",
    "dataset": "Cora",
    "hidden_dim": 256,
    "num_layers": 3,
    "dropout": 0.5,
    "lr": 0.001,
    "epochs": 200
}
print("实验配置:", config)
# Cell 2:训练结果
results = {"val_acc": 0.842, "test_acc": 0.831, "best_epoch": 167}
print(f"验证集准确率:{results['val_acc']:.3f}")
print(f"测试集准确率:{results['test_acc']:.3f}")

5.2 用 Git 管理实验历史

git add experiments/exp_2025_05_26.ipynb
git commit -m "exp: GraphSAGE baseline, test_acc=0.831"

# 回溯历史实验
git log --oneline
# a3f2c1d exp: GraphSAGE + GAT comparison
# 8b1e9d2 exp: GraphSAGE baseline, test_acc=0.831

六、自定义快捷键

keybindings.json 中添加:

[
  {
    "key": "ctrl+shift+l",
    "command": "continue.focusContinueInput",
    "comment": "打开 AI 助手"
  },
  {
    "key": "ctrl+k v",
    "command": "markdown.showPreviewToSide",
    "comment": "侧边预览 Markdown"
  }
]

七、总结:一天的科研工作流

时间 任务 使用工具
上午 阅读新论文 PDF Viewer + Continue(/explain)
上午 整理阅读笔记 Markdown + Git 提交
下午 写论文方法节 Markdown + LaTeX 公式预览
下午 润色段落 Continue(/proofread) + Gemma4
傍晚 跑对比实验 Jupyter Notebook
傍晚 记录实验结果 Notebook + Git

一个窗口,零切换,全流程覆盖。

配置参考:VS Code 1.92+,Continue 扩展 0.9+,Ollama 0.6.x,WSL2 Ubuntu 22.04。

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐