-
-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to customize the keybindings that are recognized while editing a cell value #2184
Comments
That's an interesting point. I imagine there's a good/historical reason for not exposing those keys for easy customization, but in case it helps it looks like you can still handle this with an addition to your from functools import partialmethod
from visidata import Sheet
from visidata._input import acceptThenFunc
Sheet.editCell = partialmethod(Sheet.editCell, bindings={
"^N": acceptThenFunc('go-down', 'edit-cell'),
"^P": acceptThenFunc('go-up', 'edit-cell'),
}) It's a bit awkward compared to the more typical key bindings, but probably still less messy than maintaining a personal/local fork. It's also possible that there's a different/better way to do this, or that this approach could break something else. 🧐 |
@ajkerrigan You're a total pro at the monkey-patching! We need to change the keystrokes for input keybindings to the new-style |
Hmm one way might be to optimize for the "accept and do a thing" case, maybe with an option that maps keystrokes to an iterable of functions that run after accepting input? With these sample changes, the monkeypatching suggestion turns into: vd.options.edit_accept_keybindings = {
"Ctrl+N": ("go-down", "edit-cell"),
"Ctrl+P": ("go-up", "edit-cell"),
} I'm not sure if that's the best way to handle it or not (even if it is, the naming and description could probably use some work), but it does seem a wee bit friendlier. It may be making too many assumptions though, overindexed on this particular issue. So other ideas or tweaks are very welcome. |
In visidata/_input.py on line 607, the cell-edit keybindings are hardcoded. It would be nice if we could customize these values in a config file.
My motivating example: I do a lot of manual data entry, so when I'm finished typing the value in a particular row, I want to quickly move to the next row. The shortcut to do this is
Shift+Down
, but this requires moving my hand from the numbers to the arrow keys; for a lot of data entry, this time wastage adds up fast! I wantCtrl+N
andCtrl-P
to mean "next line" and "previous line" respectively, as these are much faster to type. I actually achieved this by modifying the source code and recompiling, but it would be nice if I didn't have to resort to such measures.Thanks in advance! I'm really impressed by visidata; I only first heard of it a few hours ago. Wonderful software!
The text was updated successfully, but these errors were encountered: