Closed korakinos closed 8 years ago
Thanks for the suggestion/request! It won't go as far as promising anything, but it might prompt me to do something. :-) I can see the advantage of having insert mode maintain the original Textadept bindings (where possible). The problem I found (before the vi_global option) was that I'd keep ending up back in the default mode (after various errors etc.), which was a pain. But there's always the option of copying all the default bindings into the insert mode table at initialisation time.
There's now a function vi_mode.restore_keymap()
, which restores the key map to how it was on entry, and a vi_mode.install_keymap()
to re-install it, which may be part of the way there.
If you add something like:
do
local insert_bindings = mode_insert.bindings
for k,v in pairs(keys) do
if insert_bindings[k] == nil then
insert_bindings[k] = v
end
end
end
to the start of install_keymap()
, does that preserve the bindings in insert mode for you?
Regards,
Chris
It does, wonderful! Thank you for this, and sorry that I didn't respond earlier. (I had an old email address in my Github profile and thus didn't get notified.)
I just tried setting the undocumented option M.vi_global to false in vi_mode.lua, in order to not discard the original textadept keybindings in vi mode, but rather combine both sets of keybindings (as mentioned in another issue ). Unfortunately, it doesn't work: The movement keys "hjkl" and a few others insert letters (in command mode), after hitting "b" most keys don't work at all anymore, while "c", "r" and "i" appear to function normally.
Since the option is undocumented, this isn't really a bug. However, if you or someone else were willing to look into it anyway, I would greatly appreciate that.
One more thought: Maybe it would be even more useful to preserve the original textadept keybindings not in command mode, but in insert mode, which is closer to the non-modal context they were designed for.