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

  1. Set your preferred editor:

    export VISUAL="vim"
    # or
    export EDITOR="nano"
    
  2. In INSERT mode, press Ctrl+E

  3. Edit content in your editor

  4. Save and exit

  5. Content is updated in LazyCurl

Configuration

Environment Variables

LazyCurl checks these variables in order:

VariablePriorityDescription
$VISUAL1stPreferred editor (supports GUI)
$EDITOR2ndFallback editor
Built-in3rdnanovi (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 --wait flag to block until file is closed.

Usage

Keybinding

ContextKeyAction
INSERT mode (Body)Ctrl+EOpen body in external editor
INSERT mode (Headers)Ctrl+EOpen 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 PatternExtensionExample
Starts with { or [.jsonJSON objects/arrays
Starts with <?xml.xmlXML documents
Starts with <!doctype or <html>.htmlHTML documents
Other.txtPlain 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

ErrorCauseSolution
"No editor configured"$VISUAL and $EDITOR not setSet environment variable
"Editor not found"Editor binary not in PATHInstall editor or fix PATH
"Editor exited with error"Editor crashed or errorCheck editor logs

Error Messages

LazyCurl shows clear error messages in the statusbar:

  • Editor not found: vim - Editor binary not installed
  • No editor configured - Set $VISUAL or $EDITOR
  • Failed 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

  1. Create: Content written to temp file
  2. Edit: Editor process launched (TUI suspended)
  3. Read: Content read back after editor exits
  4. 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