laravel-prompts-vim

Vim keybindings for Laravel Prompts — drop-in replacements for text, password, and textarea that start in insert mode and support normal and visual mode editing.
Installation
composer require surgiie/laravel-prompts-vim
Usage
Import the helper functions from the package namespace instead of Laravel\Prompts:
use function Surgiie\PromptsVim\text;
use function Surgiie\PromptsVim\password;
use function Surgiie\PromptsVim\textarea;
$name = text(
label: 'Name',
placeholder: 'John Doe',
default: 'hello world',
hint: 'Press Escape to enter normal mode',
);
$pass = password(
label: 'Password',
hint: 'Press Escape to enter normal mode',
);
$bio = textarea(
label: 'Bio',
placeholder: 'Tell us about yourself...',
rows: 6,
);
All other parameters (required, validate, transform, etc.) are identical to the upstream Laravel Prompts functions.
Prompts start in insert mode. Press Escape to enter normal mode. The current mode is shown in the prompt's info line (-- INSERT --, -- NORMAL --, -- VISUAL --).
You can also use the prompt classes directly:
use Surgiie\PromptsVim\TextPrompt;
use Surgiie\PromptsVim\TextareaPrompt;
use Surgiie\PromptsVim\PasswordPrompt;
$prompt = new TextPrompt(label: 'Name');
$name = $prompt->prompt();
Supported motions
Mode switching
| Key |
Action |
Escape |
Enter normal mode (from insert or visual) |
i |
Enter insert mode before cursor |
a |
Enter insert mode after cursor |
A |
Enter insert mode at end of line |
I |
Enter insert mode at first non-whitespace |
o |
Open new line below and enter insert mode (textarea only) |
O |
Open new line above and enter insert mode (textarea only) |
v |
Enter visual mode |
Navigation
| Key |
Action |
h / ← |
Move left |
l / → |
Move right |
j / ↓ |
Move down (textarea only) |
k / ↑ |
Move up (textarea only) |
0 |
Move to start of line |
^ |
Move to first non-whitespace |
$ |
Move to end of line |
w |
Move to next word start |
b |
Move to previous word start |
e |
Move to word end |
W |
Move to next WORD start (whitespace-delimited) |
B |
Move to previous WORD start |
E |
Move to WORD end |
G |
Move to end of buffer |
gg |
Move to start of buffer |
{ |
Move to previous paragraph (textarea only) |
} |
Move to next paragraph (textarea only) |
f{c} |
Move to next occurrence of {c} on line |
F{c} |
Move to previous occurrence of {c} on line |
t{c} |
Move to one before next occurrence of {c} |
T{c} |
Move to one after previous occurrence of {c} |
Delete
| Key |
Action |
x |
Delete character under cursor |
D |
Delete to end of line |
dw / dW |
Delete to next word / WORD start |
db / dB |
Delete to previous word / WORD start |
d$ |
Delete to end of line |
d0 |
Delete to start of line |
d^ |
Delete to first non-whitespace |
dd |
Delete current line |
Change (delete + insert mode)
| Key |
Action |
s |
Substitute character under cursor |
C |
Change to end of line |
cw / cW |
Change to next word / WORD start |
cb / cB |
Change to previous word / WORD start |
c$ |
Change to end of line |
c0 |
Change to start of line |
c^ |
Change to first non-whitespace |
cc |
Change current line |
Yank & paste
| Key |
Action |
yw / yW |
Yank to next word / WORD start |
yb / yB |
Yank to previous word / WORD start |
y$ |
Yank to end of line |
y0 |
Yank to start of line |
yy |
Yank current line |
p |
Paste after cursor |
P |
Paste before cursor |
Replace & case
| Key |
Action |
r{c} |
Replace character under cursor with {c} |
~ |
Toggle case of character under cursor |
Undo
| Key |
Action |
u |
Undo last change |
Visual mode operators
Once in visual mode, extend the selection with any motion key, then apply an operator:
| Key |
Action |
d / x |
Delete selection |
y |
Yank selection |
c |
Change selection (delete + insert mode) |
p / P |
Replace selection with register |
r{c} |
Replace every character in selection with {c} |
~ |
Toggle case of selection |
u |
Lowercase selection |
U |
Uppercase selection |
u |
Undo last change (after leaving visual mode) |
License
MIT