Manim Commands / Manim 命令集
English | 中文
English
A VS Code extension that ports 3Blue1Brown's Sublime Text custom commands to VS Code. Streamlines the manimgl animation development workflow with intelligent scene detection, terminal management, and fast edit-reload cycles.
Features
| Command |
Mac |
Windows/Linux |
Description |
| Run Scene |
Cmd+Enter |
Ctrl+Enter |
Start manimgl with smart cursor detection |
| Reload |
Ctrl+Cmd+Enter |
Ctrl+Alt+Enter |
Quick reload in IPython without restarting |
| Exit |
Cmd+Shift+X |
Ctrl+Shift+X |
Exit IPython and return to shell |
| Checkpoint Paste |
Cmd+Shift+C |
Ctrl+Shift+C |
Copy selection & execute checkpoint_paste() |
| Recorded Checkpoint |
Cmd+Shift+Alt+C |
Ctrl+Shift+Alt+C |
Checkpoint paste with record=True |
| Skipped Checkpoint |
Cmd+Shift+Alt+S |
Ctrl+Shift+Alt+S |
Checkpoint paste with skip=True |
| Render |
Cmd+Shift+Enter |
Ctrl+Shift+Enter |
Stage render command (no auto-execute) |
| Open Mirrored Dir |
Cmd+Shift+Alt+O |
Ctrl+Shift+Alt+O |
Open output directory in Finder / Explorer |
Smart Cursor Detection
- Cursor on
class Xxx(Scene): line → Full animation preview
- Cursor inside class body → Skip animations (
-s), enter IPython at cursor line for fast interactive editing
This mirrors the exact behavior of 3b1b's Sublime Text workflow.
Requirements
Runtime
- VS Code
^1.103.0
- manimgl —
pip install manimgl
- Python 3.7+
Optional
- manine — alternative backend (limited IPython support)
Installation
- Install from VS Code Marketplace (search "Manim Commands")
- Or download the
.vsix from Releases and run:
code --install-extension manine-commands-0.1.0.vsix
- Configure the backend (see below)
Configuration
Open settings.json (Cmd+Shift+P → Open User Settings (JSON)) and add:
{
"manine-commands.backend": "manimgl",
"manine-commands.shellPrefix": "micromamba activate manine",
"manine-commands.mirroredDirectory.source": "/Users/you/code/videos",
"manine-commands.mirroredDirectory.target": "/Users/you/Dropbox/videos"
}
| Setting |
Default |
Description |
manine-commands.backend |
"manimgl" |
Backend to use: "manimgl" or "manine" |
manine-commands.shellPrefix |
"" |
Shell command run before manim (e.g. conda/mamba activation) |
manine-commands.mirroredDirectory.source |
"" |
Source path prefix for OpenMirroredDirectory mapping |
manine-commands.mirroredDirectory.target |
"" |
Target path prefix for OpenMirroredDirectory mapping |
Workflow
1. Open a .py file with Scene classes
2. Cmd+Enter → manimgl starts, plays scene, enters IPython
3. Edit code, save → Ctrl+Cmd+Enter → reload(N) (instant)
4. Select checkpoint code → Cmd+Shift+C → checkpoint_paste()
5. Cmd+Shift+X → exit IPython
How It Differs from Sublime
|
Sublime (Terminus) |
VS Code |
| IPython detection |
Reads terminal text buffer |
Time-based heuristic (3s delay) |
| RunScene shortcut |
Single key, auto-detects reload |
Cmd+Enter = start, Ctrl+Cmd+Enter = reload |
| All other behavior |
— |
Identical |
VS Code's terminal (xterm.js) renders to a Canvas and does not expose text content via the extension API, making Sublime-style auto-detection impossible. The extension uses a pragmatic time-based fallback.
Known Issues
-e embed injection: manimgl injects self.embed() at the cursor line. Ensure the cursor is on a valid statement line (not inside a generator expression, class body, or comment).
- First run delay: After the first
Cmd+Enter, wait ~3 seconds for manimgl to enter IPython before using Reload.
- Terminal state: The extension tracks IPython state in memory. If you manually close the terminal or exit IPython outside the extension, press
Cmd+Enter to start fresh.
中文
将 3Blue1Brown 的 Sublime Text 自定义命令移植到 VS Code 的扩展。为 manimgl 动画开发提供智能场景检测、终端管理和快速编辑-重载循环。
功能
| 命令 |
Mac |
Windows/Linux |
说明 |
| Run Scene |
Cmd+Enter |
Ctrl+Enter |
智能启动 manimgl |
| Reload |
Ctrl+Cmd+Enter |
Ctrl+Alt+Enter |
IPython 中快速重载 |
| Exit |
Cmd+Shift+X |
Ctrl+Shift+X |
退出 IPython |
| Checkpoint Paste |
Cmd+Shift+C |
Ctrl+Shift+C |
复制选中代码并执行 |
| Recorded Checkpoint |
Cmd+Shift+Alt+C |
Ctrl+Shift+Alt+C |
录制模式 |
| Skipped Checkpoint |
Cmd+Shift+Alt+S |
Ctrl+Shift+Alt+S |
跳过模式 |
| Render |
Cmd+Shift+Enter |
Ctrl+Shift+Enter |
构建渲染命令(不自动执行) |
| Open Mirrored Dir |
Cmd+Shift+Alt+O |
Ctrl+Shift+Alt+O |
Finder/资源管理器打开目录 |
智能光标检测
- 光标在
class Xxx(Scene): 行 → 完整播放动画预览
- 光标在 class 内部 → 跳过动画 (
-s),在光标行进入 IPython 交互模式
与 3b1b 的 Sublime 工作流完全一致。
依赖
运行时
- VS Code
^1.103.0
- manimgl —
pip install manimgl
- Python 3.7+
可选
安装
- 从 VS Code 插件市场搜索 "Manim Commands" 安装
- 或下载
.vsix 文件手动安装:
code --install-extension manine-commands-0.1.0.vsix
- 配置后端(见下方)
配置
打开 settings.json(Cmd+Shift+P → Open User Settings (JSON)),添加:
{
"manine-commands.backend": "manimgl",
"manine-commands.shellPrefix": "micromamba activate manine",
"manine-commands.mirroredDirectory.source": "/Users/you/code/videos",
"manine-commands.mirroredDirectory.target": "/Users/you/Dropbox/videos"
}
| 设置 |
默认值 |
说明 |
manine-commands.backend |
"manimgl" |
后端选择:"manimgl" 或 "manine" |
manine-commands.shellPrefix |
"" |
manim 命令前的 shell 前缀(如 conda 激活命令) |
manine-commands.mirroredDirectory.source |
"" |
源路径前缀 |
manine-commands.mirroredDirectory.target |
"" |
目标路径前缀 |
工作流
1. 打开包含 Scene 类的 .py 文件
2. Cmd+Enter → manimgl 启动,播放场景,进入 IPython
3. 修改代码,保存 → Ctrl+Cmd+Enter → reload(N)(秒级响应)
4. 选中 checkpoint 代码 → Cmd+Shift+C → checkpoint_paste()
5. Cmd+Shift+X → 退出 IPython
与 Sublime 的差异
|
Sublime (Terminus) |
VS Code |
| IPython 检测 |
读取终端文本缓冲区 |
基于时间的推断(3 秒延迟) |
| RunScene 快捷键 |
一个按键,自动判断 reload |
Cmd+Enter = 启动,Ctrl+Cmd+Enter = 重载 |
| 其余行为 |
— |
完全一致 |
VS Code 的终端(xterm.js)渲染到 Canvas,不通过扩展 API 暴露文本内容,无法实现 Sublime 式的自动检测。扩展使用了基于时间的实用替代方案。
已知问题
-e 注入位置:manimgl 在光标行注入 self.embed()。请确保光标在有效的语句行上(不在生成器表达式、类体或注释内)。
- 首次启动延迟:第一次
Cmd+Enter 后等待约 3 秒,manimgl 进入 IPython 后再使用 Reload。
- 终端状态:扩展在内存中跟踪 IPython 状态。如果手动关闭终端或在扩展外退出 IPython,按
Cmd+Enter 重新启动即可。
Release Notes
0.1.0
- 8 个命令全部实现(RunScene、Reload、Exit、CheckpointPaste × 3、Render、OpenMirroredDirectory)
- 智能光标检测:class 行 = 完整动画,内部 = 跳过 + IPython
- 终端管理:按名称查找、自动创建、Ctrl+L 居中
- 可配置后端(manimgl/manine)和 shell 前缀
- macOS / Windows / Linux 默认快捷键
checkpoint_paste() 剪贴板交互
0.0.2
0.0.1