Inline Editor logo

Inline Editor

CommunityPopular
marcus
inline-editor

Inline text editing implementation within the file browser preview pane using tmux PTY backend, cursor movement, text manipulation, and editor state management. Covers entry/exit lifecycle, dimension calculations, confirmation dialogs, click-away detection, mouse forwarding, and app-level key routing. Use when working on inline editing features, text input components, or debugging editor rendering/input issues in the file browser plugin.

Overview

Publishermarcus
Repositorysidecar
Skill nameinline-editor
Stars
1.1K
Forks
82
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by marcus on GitHub. Read the source before you install it.

Installation

Install the Inline Editor AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/marcus/sidecar/tree/main/.claude/skills/inline-editor
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/marcus/sidecar.git /tmp/sidecar
mkdir -p .claude/skills
cp -r /tmp/sidecar/.claude/skills/inline-editor .claude/skills/inline-editor
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Inline Editor in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Inline Editor on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Inline Editor is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Inline Editor Implementation

Overview

The inline editor (tmux_inline_edit) lets users edit files directly within the file browser preview pane using their preferred terminal editor (vim, nvim, nano, etc.) without leaving the TUI. The file tree remains visible during editing.

Core Principle: This is NOT a terminal emulator. Tmux manages the PTY backend; Sidecar acts as an input/output relay, similar to the workspace plugin's interactive mode.

Architecture

Components

  1. Entry Layer (internal/plugins/filebrowser/inline_edit.go): Creates tmux sessions, manages editor lifecycle
  2. Rendering Layer (internal/plugins/filebrowser/view.go, inline_edit.go): Renders editor content within preview pane
  3. Input Layer (internal/plugins/filebrowser/plugin.go, mouse.go): Routes keys/clicks to editor or confirmation dialog
  4. TTY Model (internal/tty/tty.go): Handles tmux capture, cursor overlay, and input forwarding

Data Flow

User presses 'e' on file
  -> enterInlineEditMode()
  -> tmux new-session -d -s {sessionName} {editor} {path}
  -> InlineEditStartedMsg
  -> handleInlineEditStarted()
  -> tty.Model.Enter()
  -> Start polling tmux capture-pane
  -> renderInlineEditorContent() in preview pane
  -> User types -> tty.Model forwards to tmux
  -> User exits -> SessionDeadMsg or exit keys
  -> exitInlineEditMode()
  -> Refresh preview

Key Files

FilePurpose
internal/plugins/filebrowser/inline_edit.goEditor lifecycle, confirmation dialog, dimension calculations
internal/plugins/filebrowser/view.goPreview pane rendering, gradient border
internal/plugins/filebrowser/mouse.goClick-away detection
internal/plugins/filebrowser/plugin.goState management, Update routing
internal/tty/tty.goTTY model for tmux interaction (shared with workspace)
internal/app/update.goApp-level key routing for inline edit context

Critical Implementation Details

1. Preview Pane Rendering (Not Full-Screen)

The editor renders within renderPreviewPane(), NOT as a full-screen takeover. The file tree stays visible.

go
// view.go - renderPreviewPane()
func (p *Plugin) renderPreviewPane(visibleHeight int) string {
    if p.inlineEditMode && p.inlineEditor != nil && p.inlineEditor.IsActive() {
        return p.renderInlineEditorContent(visibleHeight)
    }
    // ... normal preview rendering
}

2. Dimension Calculations

The tty.Model needs exact dimensions matching the preview pane content area:

go
func (p *Plugin) calculateInlineEditorWidth() int {
    if !p.treeVisible {
        return p.width - 4 // borders + padding
    }
    p.calculatePaneWidths()
    return p.previewWidth - 4
}

func (p *Plugin) calculateInlineEditorHeight() int {
    paneHeight := p.height
    innerHeight := paneHeight - 2 // pane borders
    contentHeight := innerHeight - 2 // header lines
    if len(p.tabs) > 1 {
        contentHeight-- // tab line
    }
    return contentHeight
}

These MUST stay in sync with renderInlineEditorContent() layout calculations.

3. Confirmation Behavior

Rule: session alive = show confirmation, session dead = exit immediately.

Always show confirmation when the session is alive, regardless of file modification status. Vim's modification status cannot be reliably detected externally.

go
func (p *Plugin) isInlineEditSessionAlive() bool {
    if p.inlineEditSession == "" {
        return false
    }
    err := exec.Command("tmux", "has-session", "-t", p.inlineEditSession).Run()
    return err == nil
}

Check session alive status:

  1. At the start of Update() when in inline edit mode - if dead, exit immediately
  2. In click-away handling - if dead, skip confirmation and clean up

4. Exit Confirmation Dialog

State fields:

go
showExitConfirmation bool        // Dialog visible
pendingClickRegion   string      // Where user clicked
pendingClickData     interface{} // Click data (tree index, tab index)
exitConfirmSelection int         // 0=Save&Exit, 1=Exit without saving, 2=Cancel

Options:

  • Save & Exit: Sends editor-appropriate save-and-quit sequence, waits for session death
  • Exit without saving: Kills tmux session immediately
  • Cancel: Returns to editing

5. Click-Away Detection

Mouse regions are registered during render. Clicks between items may miss regions, so always include position-based fallback:

go
if p.inlineEditMode && p.inlineEditor != nil && p.inlineEditor.IsActive() {
    action := p.mouseHandler.HandleMouse(msg)

    handleClickAway := func(regionID string, regionData interface{}) (*Plugin, tea.Cmd) {
        if !p.isInlineEditSessionAlive() {
            p.exitInlineEditMode()
            p.pendingClickRegion = regionID
            p.pendingClickData = regionData
            return p.processPendingClickAction()
        }
        p.pendingClickRegion = regionID
        p.pendingClickData = regionData
        p.showExitConfirmation = true
        p.exitConfirmSelection = 0
        return p, nil
    }

    if action.Type == mouse.ActionClick {
        if action.Region != nil {
            switch action.Region.ID {
            case regionTreePane, regionTreeItem, regionPreviewTab:
                return handleClickAway(action.Region.ID, action.Region.Data)
            }
        }
        // Fallback: position-based detection
        if p.treeVisible && action.X < p.treeWidth {
            return handleClickAway(regionTreePane, nil)
        }
    }
    // Forward to tty model
    return p, p.inlineEditor.Update(msg)
}

6. Gradient Border Feedback

Visual indicator that edit mode is active:

go
if p.inlineEditMode && p.inlineEditor != nil && p.inlineEditor.IsActive() {
    rightPane = styles.RenderPanelWithGradient(previewContent, p.previewWidth,
        paneHeight, styles.GetInteractiveGradient())
}

7. Mouse Support (SGR Protocol)

Full mouse interaction including text selection via SGR (1006) protocol. Mouse events are forwarded to the tty model which translates them into SGR escape sequences: \x1b[<button;x;y;M/m where M = press/drag, m = release.

8. Multi-Editor Support

sendEditorSaveAndQuit() detects which editor is running and sends the appropriate sequence:

EditorSave & Quit Command
vim, nvim, viEscape :wq Enter
nanoCtrl+O Enter Ctrl+X
emacsCtrl+X Ctrl+S Ctrl+X Ctrl+C
helixEscape :wq Enter
microCtrl+S Ctrl+Q
kakouneEscape :write-quit Enter
joeCtrl+K X
neEscape :SaveQuit Enter
ampCtrl+S Ctrl+Q

Exit Paths

MethodConfirmationDescription
Ctrl+\NoImmediate exit (tty.Config.ExitKey)
Double-ESCNoExit with 150ms delay (vim ESC compatibility)
:q, :wq in vimNoNormal editor exit, session death detected
Click tree/tabYes (if alive)Shows confirmation when session alive; exits immediately if dead

State Management

Plugin State (plugin.go)

go
inlineEditor         *tty.Model // Embeddable tty model
inlineEditMode       bool       // Currently editing
inlineEditSession    string     // Tmux session name
inlineEditFile       string     // File being edited
showExitConfirmation bool
pendingClickRegion   string
pendingClickData     interface{}
exitConfirmSelection int

Update Priority (plugin.go)

go
func (p *Plugin) Update(msg tea.Msg) (plugin.Plugin, tea.Cmd) {
    // 1. Handle exit confirmation dialog FIRST
    if p.showExitConfirmation { /* j/k navigation, Enter confirm, Esc cancel */ }
    // 2. Handle inline edit mode
    if p.inlineEditMode && p.inlineEditor.IsActive() { /* Delegate to tty.Model */ }
    // 3. Normal plugin handling
}

App-Level Key Routing

The app intercepts global shortcuts (q, 1-5, `, ~, ?, !, @) before plugins. For inline edit to receive ALL keys, internal/app/update.go must recognize the context:

go
if m.activeContext == "workspace-interactive" || m.activeContext == "file-browser-inline-edit" {
    // Forward ALL keys to plugin
}

The plugin returns "file-browser-inline-edit" from FocusContext().

Common Pitfalls

  1. Do NOT render full-screen - render within preview pane only, keeping file tree visible
  2. Always include position-based click fallback - mouse regions may not cover every pixel
  3. Always confirm on click-away when session is alive - prevents accidental data loss
  4. Check IsActive() on every message - tty model can become inactive asynchronously; without this check, users get a blank screen after vim exits
  5. Never query tmux synchronously in View() - use cached content from tty.Model.View()
  6. Handle tab row clicks by Y position BEFORE region-based detection - prevents incorrect handling as preview pane clicks
  7. Ensure app-level key routing recognizes "file-browser-inline-edit" context - otherwise typing q in vim triggers quit instead of inserting character

Feature Flag

Gated behind tmux_inline_edit. Enable in ~/.config/sidecar/config.json:

json
{ "features": { "tmux_inline_edit": true } }

Fallback: features.IsEnabled(features.TmuxInlineEdit.Name) returns false -> opens external editor.

Keyboard Shortcuts

KeyCommandDescription
eeditEdit file inline (within preview pane)
Eedit-externalEdit in full terminal (suspends TUI)

Registered in:

  • internal/plugins/filebrowser/plugin.go - Commands() method
  • internal/plugins/filebrowser/handlers.go - Key handling
  • internal/keymap/bindings.go - Key bindings for file-browser-tree and file-browser-preview contexts

References

  • Interactive shell guide: docs/guides/deprecated/interactive-shell-implementation.md
  • TTY model: internal/tty/tty.go
  • Feature flags: internal/features/features.go

Frequently asked questions

What does the Inline Editor AI skill do?

Inline text editing implementation within the file browser preview pane using tmux PTY backend, cursor movement, text manipulation, and editor state management. Covers entry/exit lifecycle, dimension calculations, confirmation dialogs, click-away detection, mouse forwarding, and app-level key routing. Use when working on inline editing features, text input components, or debugging editor rendering/input issues in the file browser plugin.

Why use Inline Editor on TypingMind?

Because you install it once and use it with any model. Inline Editor is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Inline Editor in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/marcus/sidecar/tree/main/.claude/skills/inline-editor. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Inline Editor?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Inline Editor?

As many as you like. As long as a model supports skills, you can use Inline Editor with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Inline Editor AI skill free?

Yes. It is published on GitHub by marcus under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇