External Editor Integration
January 17, 2026 · View on GitHub
Edit request bodies and headers in your preferred text editor with full syntax highlighting and editor features.
Overview
LazyCurl can launch external editors (vim, VS Code, nano, etc.) to edit request content. This is useful for:
- Editing large JSON payloads
- Using editor-specific features (snippets, formatting)
- Familiar editing environment
Quick Start
-
Set your preferred editor:
export VISUAL="vim" # or export EDITOR="nano" -
In INSERT mode, press
Ctrl+E -
Edit content in your editor
-
Save and exit
-
Content is updated in LazyCurl
Configuration
Environment Variables
LazyCurl checks these variables in order:
| Variable | Priority | Description |
|---|---|---|
$VISUAL | 1st | Preferred editor (supports GUI) |
$EDITOR | 2nd | Fallback editor |
| Built-in | 3rd | nano → vi (first found) |
Editor Examples
Terminal Editors:
export VISUAL="vim"
export VISUAL="nvim"
export VISUAL="nano"
export VISUAL="emacs"
export VISUAL="micro"
GUI Editors:
# VS Code (--wait is required)
export VISUAL="code --wait"
# Sublime Text
export VISUAL="subl --wait"
# Atom (deprecated)
export VISUAL="atom --wait"
# gedit
export VISUAL="gedit"
Important: GUI editors must use
--waitflag to block until file is closed.
Usage
Keybinding
| Context | Key | Action |
|---|---|---|
| INSERT mode (Body) | Ctrl+E | Open body in external editor |
| INSERT mode (Headers) | Ctrl+E | Open headers in external editor |
Workflow
┌─────────────────────────────────────────────────────┐
│ 1. Press Ctrl+E in INSERT mode │
│ ↓ │
│ 2. LazyCurl creates temp file with content │
│ ↓ │
│ 3. Editor opens with appropriate extension │
│ (.json, .xml, .txt based on content) │
│ ↓ │
│ 4. Edit content, save, and exit editor │
│ ↓ │
│ 5. LazyCurl reads updated content │
│ ↓ │
│ 6. Temp file is cleaned up │
└─────────────────────────────────────────────────────┘
Content Type Detection
LazyCurl automatically detects content type and uses appropriate file extension:
| Content Pattern | Extension | Example |
|---|---|---|
Starts with { or [ | .json | JSON objects/arrays |
Starts with <?xml | .xml | XML documents |
Starts with <!doctype or <html> | .html | HTML documents |
| Other | .txt | Plain text |
This enables:
- Syntax highlighting in editors
- Format-specific plugins/extensions
- Auto-formatting on save
Headers Editing
When editing headers, they are serialized as text:
Content-Type: application/json
Authorization: Bearer {{token}}
X-Custom-Header: value
Edit as plain text, one header per line in Name: Value format.
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
| "No editor configured" | $VISUAL and $EDITOR not set | Set environment variable |
| "Editor not found" | Editor binary not in PATH | Install editor or fix PATH |
| "Editor exited with error" | Editor crashed or error | Check editor logs |
Error Messages
LazyCurl shows clear error messages in the statusbar:
Editor not found: vim- Editor binary not installedNo editor configured- Set$VISUALor$EDITORFailed to create temp file- Disk/permission issue
Advanced Usage
Using Different Editors per Content Type
While not directly supported, you can use wrapper scripts:
#!/bin/bash
# ~/bin/smart-editor
case "\$1" in
*.json) code --wait "\$1" ;;
*.xml) vim "\$1" ;;
*) nano "\$1" ;;
esac
export VISUAL="~/bin/smart-editor"
SSH Remote Editing
For remote development, ensure your editor supports remote files:
# VS Code Remote
export VISUAL="code --wait --remote ssh-remote+myserver"
Troubleshooting
Editor Opens But Content Not Updated
Cause: Editor exited before file was saved.
Solution: Ensure you save (:w in vim, Ctrl+S in others) before exiting.
GUI Editor Opens New Window
Cause: Missing --wait flag.
Solution: Add --wait to your editor command:
export VISUAL="code --wait"
Content Lost After Edit
Cause: Editor crashed or force-quit.
Solution: Temp files are in system temp directory. Check for recovery.
Wrong Syntax Highlighting
Cause: Content type detection failed.
Solution: Content type is detected from content start. Ensure valid JSON/XML prefix.
Technical Details
Temp File Location
- macOS:
/var/folders/.../lazycurl-*.ext - Linux:
/tmp/lazycurl-*.ext - Windows:
%TEMP%\lazycurl-*.ext
File Lifecycle
- Create: Content written to temp file
- Edit: Editor process launched (TUI suspended)
- Read: Content read back after editor exits
- Cleanup: Temp file deleted
Process Handling
- TUI is suspended during editing (
tea.ExecProcess) - Editor runs in foreground with full terminal control
- Exit code 0 indicates success
- Non-zero exit code shows error message
See Also
- Keybindings - All keyboard shortcuts
- Configuration - General configuration
- Getting Started - First steps with LazyCurl