The /edit command uses the editor-command crate to automatically detect and launch your preferred text editor.
The editor-command crate handles editor detection and invocation across all major platforms (macOS, Linux, Windows) and integrates seamlessly with VT Code's TUI environment.
The guided setup is available from the TUI:
- Run
/config, then selectExternal Editorfrom the root quick-access list. - Run
/config tools.editorto jump straight into the same wizard. - The wizard configures
/edit,Ctrl+Ewhen the prompt is empty, and single-click file links in the TUI. - After saving editor settings, the flow can also take you to
/config file_openerfor ANSI hyperlink URI behavior. - In the custom-command step, pressing
Enteron an empty inline input keeps the displayed default command.
Editor settings are configured in the [tools.editor] section of vtcode.toml:
[tools.editor]
# Enable external editor support for /edit command
enabled = true
# Leave empty to use automatic detection based on environment variables
# Supports command arguments (example: "code --wait")
# Examples: "vim", "nvim", "emacs", "nano", "code", "code --wait", "zed", "subl -w"
preferred_editor = ""
# Suspend the TUI while VT Code is waiting on the editor process
suspend_tui = trueWhen no preferred_editor is specified, VT Code uses a two-stage detection process:
VISUALenvironment variable (highest priority)EDITORenvironment variable
If neither environment variable is set, VT Code tries common editors in PATH:
Unix/Linux/macOS:
nvim(Neovim - preferred)vimvinanoemacs
Windows:
code(Visual Studio Code)notepad++notepad
/edit
This opens your default editor with a temporary file. The file contents are returned and inserted into your input when you save and close the editor.
/edit src/main.rs
Opens src/main.rs in your preferred editor.
When suspend_tui = false, VT Code now keeps the TUI live for real file opens and returns immediately after launching the external editor. Temporary-file /edit flows still wait, because VT Code has to read the edited content back into the composer.
Single-clicking a file path in the transcript or a modal uses the same editor workflow and respects configured line and column targets when the selected editor supports them.
/edit path/to/file.txt
Paths are resolved relative to the workspace root.
macOS/Linux:
export EDITOR=nvim # Lower priority
export VISUAL=vim # Higher priority (takes precedence)Windows (PowerShell):
$env:EDITOR = "code"
$env:VISUAL = "code"Edit vtcode.toml:
[tools.editor]
preferred_editor = "nvim" # Override automatic detectionThe crate automatically detects these editors:
CLI Editors:
vim,vinvim(Neovim)nanoemacspico
GUI Editors:
code(Visual Studio Code)zedgedit(GNOME)geanycode-osssubl(Sublime Text)atommate(TextMate)open -a TextEdit(macOS)
The suspend_tui = true setting (recommended) ensures:
- TUI event loop is suspended before launching the editor
- Terminal alternate screen is properly exited
- Pending events are drained (prevents input garbage)
- Raw mode is disabled for the editor
- Terminal state is restored when the editor closes
- Screen is cleared to remove artifacts
This prevents terminal corruption and input conflicts when switching between VT Code and external editors.
This error means no editor was found. VT Code checks both environment variables and fallback editors.
Solution (choose one):
-
Set EDITOR environment variable (recommended):
export EDITOR=vim # or export VISUAL=nvim
-
Install a common editor:
# macOS brew install neovim # Ubuntu/Debian sudo apt install neovim # or use nano (usually pre-installed) which nano
-
Explicitly configure in vtcode.toml:
[tools.editor] preferred_editor = "vim"
Verify the editor is accessible:
which nvim # or your editor name
echo $EDITOR
echo $VISUALIf the editor is in PATH but not detected, set EDITOR explicitly:
export EDITOR=/usr/bin/nvim- Ensure
suspend_tui = trueto prevent terminal state issues - Check if your editor has special terminal requirements
- Consider using a different editor if problems persist
When using /edit without a file argument:
- A temporary file is created
- Your editor is launched
- When you save and close the editor, content is returned
- The temporary file is automatically deleted
Ensure you actually save the file in your editor (e.g., :w in vim) before closing.
The /edit command works with:
- File browser - Select files to edit using
@symbol or/files - Workspace context - Editors open with workspace root as working directory
- Tool policies - Controlled via
[tools.policies]section (default:"allow")