saulpw / visidata

A terminal spreadsheet multitool for discovering and arranging data
http://visidata.org
GNU General Public License v3.0
7.88k stars 279 forks source link

vi mode when editing #1669

Closed laktak closed 1 year ago

laktak commented 1 year ago

As you already support vi/vim style navigation, would it be possible to support it when editing a cell?

I've seen ctrl+o but I'd prefer editing inline either with a python implementation or by using readline.

saulpw commented 1 year ago

Hi @laktak, I assume this means you'd have a modal interface so that at first, after pressing e to edit the cell, you could move around with 0hl$ and then press e.g. i to insert at the cursor, a to insert after the cursor, Shift+A to append to the string, and then press Esc to get back to movement mode? Maybe q to save the cell and exit VisiData's editing mode? What's the full list of vi commands that should be supported for something like this?

readline can't be used within a curses TUI application, and I'm not interested in implementing this (despite being a full-time vim user), but if someone wants to put up a prototype PR I would consider it, if the complexity/code cost is not too large.

Kondo'ed for now.

laktak commented 1 year ago

Yes, what you describe is similar to what sc-im does.

I also have some python code that may be useful here https://github.com/laktak/ranger/blob/viconsole/ranger/gui/widgets/console.py#L438

I may come back to do a PR once I get to know visidata better.

saulpw commented 1 year ago

Please do, @laktak! I've been thinking about how the input mechanism could be expanded to a popup 'form' modal dialog that can be filled out and return a dict, and that would want some basic multi-line editing, which would go well with this feature. Feel free to come by and say hi on visidata.org/chat and we can talk about it.