How can I make a vim function wait for a single key press?
Example:
f is pressedf is pressed nothing should help right awayx) is pressed, the cursor should move to the next ocurrence of xPS: Yes, I know that's exactly what
fdoes by default (although its only linewise), but I was wondering if WE could implement functionality like this, ourselves
What if I want to wait for the next two keypresses, is that also possible?
You can use the built-in getchar() function. It waits for a single keypress and then returns it. For an ordinary 8-bit character, you have to use nr2char(getchar()) to convert it to a String.
It seems you want to extend the f / t commands to cover multiple lines, too. Be aware that there are already plugins that do that, for example ft_improved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With