summaryrefslogtreecommitdiff
path: root/pi/agent/extensions/modal-editor/README.md
blob: bc5a86b0995240d4fa1244b46f6cf2f17bab9e98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Modal Editor

Modal prompt editing for the Pi TUI.

This is now a custom Helix-leaning modal editor for your dotfiles-backed Pi
tree. It replaces the earlier upstream toy example with a more capable normal
mode and a few prompt-editing operations that are actually useful in daily use.

## What It Does

- starts in `NORMAL` mode
- `Esc` leaves `INSERT` mode and returns to `NORMAL`
- `h`, `j`, `k`, `l` move in `NORMAL`
- `b`, `w`, `e` handle word motions in `NORMAL`
- `gh` goes to line start and `gl` goes to line end
- `gg` goes to the start of the prompt and `ge` goes to the end
- `i`, `a`, `I`, `A`, `o`, `O` enter insert mode in useful places
- `x` deletes the current character
- `D` deletes from the cursor to line end
- `dd`, `dw`, `de`, `db`, `d0`, and `d$` handle common deletes
- `u` undoes the last change

## Usage Flows

### Flow 1: Edit a prompt normally

1. Start Pi in a real terminal session.
2. You begin in `NORMAL`.
3. Move with `h`, `j`, `k`, `l`.
4. Jump by word with `b`, `w`, `e`.
5. Press `i` to start inserting text.

### Flow 2: Append instead of inserting

1. Press `a` to append after the cursor.
2. Press `A` to append at line end.
3. Press `I` to insert at line start.

### Flow 3: Use Helix-style line motions

Move to line start:

```text
gh
```

Move to line end:

```text
gl
```

You still also have `0` and `$` if you want the Vim-style single-key versions.

### Flow 4: Delete text without dropping into insert mode

Delete a character:

```text
x
```

Delete the current line:

```text
dd
```

Delete to the next word boundary:

```text
dw
```

Delete to word end:

```text
de
```

Delete from the cursor to the end of the current line:

```text
D
```

### Flow 5: Abort agent work from normal mode

When Pi is already running an agent action, `Esc` in `NORMAL` passes through to
the app-level handling, so the usual abort behavior still works.

## Notes And Limits

- This only affects interactive Pi TUI sessions.
- It does not matter in one-shot `pi -p` mode.
- This is still constrained by Pi's underlying editor model. It is a
  Helix-leaning prompt editor, not a full Helix clone with multiple selections,
  text objects, or the entire command surface.