An open API service indexing awesome lists of open source software.

https://github.com/liunuozhi/pi-vi

Minimal vi-style modal editing for Pi's TUI prompt
https://github.com/liunuozhi/pi-vi

modal-editing pi pi-extension terminal tui vi vim

Last synced: about 1 month ago
JSON representation

Minimal vi-style modal editing for Pi's TUI prompt

Awesome Lists containing this project

README

          

# pi-vi

Minimal vi-style modal editing for Pi's input prompt. Trimmed to the muscle-memory core.

## install

```bash
pi install npm:@liunuozhi/pi-vi
```

Restart Pi after install.

## commands

Small key set. No counts, no `;`/`,`, no text objects, no EX mode, no clipboard sharing.

### mode

| key | action |
|-----|--------|
| `Esc` | Insert → Normal |
| `i` | Insert at cursor |
| `I` | Insert before first non-blank |
| `a` | Insert after cursor |
| `A` | Append at line end |
| `o` | Open line below + Insert |
| `O` | Open line above + Insert |

### motion (Normal)

| key | action |
|-----|--------|
| `h` `j` `k` `l` | left / down / up / right |
| `0` / `$` | line start / line end |
| `w` / `b` | next word / previous word |
| `gg` / `G` | top / bottom of buffer |
| `f{c}` / `F{c}` | jump to `c` (forward / backward, inclusive) |
| `t{c}` / `T{c}` | jump up to `c` (forward / backward, exclusive) |

### edit (Normal)

| key | action |
|-----|--------|
| `x` | delete char under cursor |
| `dd` | delete line |
| `dw` | delete word forward |
| `df{c}` / `dt{c}` | delete to `c` (inclusive / exclusive) |
| `D` | delete to end of line |
| `cc` | change line (delete + Insert) |
| `cw` | change word (delete + Insert) |
| `cf{c}` / `ct{c}` | change to `c` |
| `C` | change to end of line |

### copy / paste

| key | action |
|-----|--------|
| `yy` | yank line into internal register |
| `p` | paste internal register after cursor |

### undo

| key | action |
|-----|--------|
| `u` | undo |

## architecture

- `index.ts` — `ModalEditor` extends `CustomEditor`; all key handling.
- `motions.ts` — pure `findWordMotionTarget` and `findCharMotionTarget`.

Run checks:

```
npm install
npm run typecheck
```

## credits

Inspired by [lajarre/pi-vim](https://github.com/lajarre/pi-vim), which covers the high-frequency 90% of vim. `pi-vi` trims that further to the muscle-memory core.