Replies: 5 comments 1 reply
-
Interesting! I knew it was possible to remap keys in vim, but never realized you could remap the escape key like that. Do you use that for other modes besides insert/visual as well? (for example, would typing "/kk" would enter and then immediately exit search mode? or search for the string "kk")
Need to think a bit about how to approach this. Aretext currently defines the key mappings statically (for example, this is where the Escape key gets mapped to the "return to normal mode" command). This is basically a giant regular expression that gets compiled to bytecode and embedded in the aretext binary. The bytecode contains instructions for interpreting an "escape" key event as the "return to normal mode command". To remap the escape key (single key event) to a sequence like "kk" (two key events) in the current implementation, the bytecode would need to change. A few possibilities: if remapEsc is configured, recompile the bytecode at runtime? That would take maybe a few hundred ms, but could work. Or maybe do something clever like run another "remapping" VM (compiled at runtime) to translate "kk" to the escape key event, then pass the translated events to the original input VM. I'd also be curious to hear if there are other use-cases that involve remapping keys. Might be worth building something for remapping in general rather than just for remapping the escape key.
That's probably your best bet for now. Should be as simple as editing the
Thanks for the kind words! Glad you're enjoying it! |
Beta Was this translation helpful? Give feedback.
-
Thank you for replying so quickly! Although I have used vim for a bit, I only recently have started to try to "learn" it a bit better. I haven't found any other use of the feature besides leaving insert or visual mode or disabling the arrow keys (to force yourself to learn the hjkl navigation keys). In my .vimrc, they look like this:
One side-effect of remapping "kk" to There is another group of vimmers who map the "Caps Lock" key to
Well, I have seen a few different ones in dotfiles here and there. A few people remap Mapping specific actions to
Sounds like a plan! Thank you very much for taking the time to read my feature request! |
Beta Was this translation helpful? Give feedback.
-
converting this issue into a discussion. I'm open to implementing a more general key-remapping mechanism in the future, but need to think more about the technical design and use cases. |
Beta Was this translation helpful? Give feedback.
-
Thank you for opening this discussion! |
Beta Was this translation helpful? Give feedback.
-
In the end I stopped using "kk" and remapped Caps Lock as Esc. Because this is a system-level setting, it requires no configuration anywhere. Other people may be interested in this but I think this option works best for me in the long run :) |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I was wondering if it would be possible to allow a setting to "remap" to "kj", "kk" and similar. They are very popular remapping of the key that are used regularly in Vim to avoid hitting the out-of-the-way Esc key.
Describe the solution you'd like
It would be great to have something like:
pattern: "**"
config:
remapEsc: "kk"
Describe alternatives you've considered
I could modify the source code to change the mapping for my own use, but I thought other people might be interested.
Additional context
Just to say, I love your editor :)
Beta Was this translation helpful? Give feedback.
All reactions