darrenburns / posting

The modern API client that lives in your terminal.
Apache License 2.0
4.48k stars 64 forks source link

Add support form vim style key bindings #34

Open kylemhall opened 2 months ago

kylemhall commented 2 months ago

It would be really great to have support for vim-style key bindings!

darrenburns commented 2 months ago

I assume you mean in the request body editor? 😄

Let me know which keys in particular you would like.

kylemhall commented 2 months ago

That is correct!

I grabbed this bit from https://www.freecodecamp.org/news/vim-key-bindings-reference/ I think most of these could be added without too much fuss. I imagine things like insert vs visual mode might be more difficult.

Moving to Top and Bottom

You can use these keys to move to the top or bottom of the page:

gg --> Move to the first line of the page G --> Move to the last line of the page How to Edit Text in Normal Mode Deletion and Copying

You can delete or copy characters using these keys:

x --> Delete the character under the cursor dd --> Delete the entire line yy --> Copy (yank) the entire line p --> Paste the previously deleted or copied text after the cursor

Undo and Redo

u --> Undo the last action Ctrl + r --> Redo the undone action

Thanks!

darrenburns commented 2 months ago

These binds would require the addition of an insert mode though. Quite a few Vim bindings already work in the response area since that's read only. However, I would need to add a mode system in order to support the ones you've listed in the request area.

Possibly in the future I'll look at this, but for now you can easily edit the request in Vim by pressing f4 (assuming you have your EDITOR env var set).

kylemhall commented 2 months ago

Excellent, thanks for that tip!

diegoulloao commented 2 months ago

It would be great to move 10 lines up/down by pressing ctr+u/ctrl+d in the response widget (json), just like vim.

darrenburns commented 2 months ago

I've added ctrl+d and ctrl+u in 1.2.0.

diegoulloao commented 1 month ago

IMHO, due request body is read-only, I think other keybindings for edit shouldn't be included, for editing you can just open the editor. Said that, and the fact that basic movements are already implemented, this issue could be mark as done (?)