visual-mode.kak is my first attempt at a plugin; it emulates vim’s visual modes (character- and line-wise). Coming from vim, it’s a bit annoying having to hold down shift all the time, so I put this together and have been using it in my kakrc for a while, but I figured others might find it useful, so I factored it out to a plugin.
I’m still relatively new to Kakoune, so it’s possible I’m not doing everything the best way. Any feedback on the usability or implementation are welcome.
Hi, thanks for sharing! Did you have to do all the work with the hooks to get a behaviour of making unmapped keys fall back to normal mode keys? I’ve also wanted to have that fallback behaviour, it would be good if enter-user-mode had a flag for it.
@danr that’s right, basically all of the many hooks are just to make kakoune escape the user mode back to normal mode, and then press the same key. There were a surprising number of gotchas, like the fact that the event that signals entering and exiting user mode happens on every key press (see #4513). And also that if the user just hits escape, this doesn’t trigger the inner RawKey hook, so another hook was required to remove the other hooks!
It would be much easier if there were an option to just pass through unmapped keys to normal mode.
I remembered having a stab at implementing what is
called “real custom modes” in #3441 here:
I never got around to actually using it. But it is a way to add an indirection in the kakoune normal mode mapping to look up in custom modes.
Anyways, this would all be better to solve in the C++ code to add some kind of fallthrough.
Although another lazy way to work around this is to first prepopulate the user mode with all keys forwarding to normal mode. But it messes up the info box since it is now full of fallthrough forwarders. So the lazy thing is to add a -hidden flag to map