# pi-editor-picker

Pick and configure external editors for Pi (Ctrl+G).

## Why this package?

Pi's built-in `externalEditor` setting supports `$VISUAL`, `$EDITOR`, and commands like `code --wait`. But on Windows, many popular editors are GUI programs that **return immediately after launch** — Pi reads back an empty file before you finish editing.

This package fills the gap:

- Wraps Windows GUI editors so Pi **waits for the window to close**
- Auto-detects editor locations from **registry, Start Menu, and common paths**
- Sets `externalEditor` with **one command**, no manual config editing
- **Auto-fallbacks** — request an editor not installed, it picks the next best one

## Editors Pi can't handle natively (this package can)

| Editor | Why Pi can't handle it | What this package does |
|--------|------------------------|------------------------|
| **Typora** | GUI app, no `--wait` flag | Shortcut + `cmd /c start /w` |
| **MarkText** | GUI app, no `--wait` flag | Shortcut + `cmd /c start /w` |
| **Notepad++** | GUI app, no `--wait` flag | Shortcut + `cmd /c start /w` |
| **Notepad** | Already natively supported | Included for one-click selection |

> These GUIs work automatically on Windows. Close the window to return to Pi.

## Editors Pi natively supports (also included)

| Editor | Pi native command | This package also provides |
|--------|-------------------|----------------------------|
| VS Code | `code --wait` | One-click `/editor vscode` |
| Cursor | `cursor --wait` | One-click `/editor cursor` |
| Windsurf | `windsurf --wait` | One-click `/editor windsurf` |
| Sublime Text | `subl -w` | One-click `/editor sublime` |
| Atom | `atom --wait` | One-click `/editor atom` |
| Zed | `zed --wait` | One-click `/editor zed` |
| Neovim | `nvim` | One-click `/editor neovim` |
| Vim | `vim` | One-click `/editor vim` |
| Emacs | `emacs -nw` | One-click `/editor emacs` |

## Platform support

- **Windows**: Full support — GUI wrappers, registry + Start Menu detection.
- **macOS / Linux**: CLI editors and `--wait` editors only. Windows GUI editors are not detected.

## Installation

```bash
pi install npm:pi-editor-picker
```

Or add to your `~/.pi/agent/settings.json`:

```json
{
  "packages": ["npm:pi-editor-picker"]
}
```

Then `/reload`.

## Usage

```text
/editor                    Interactive picker
/editor list               List detected editors
/editor auto               Auto-select the first available
/editor typora             Select Typora directly
/editor select typora      Same as above
/editor vscode             Select VS Code directly
```

After selecting, run `/reload` to apply, then press `Ctrl+G` to open the external editor.

## License

MIT
