To understand what I'm referring about, think of screenkey.

As for why I'd like such a plugin, here's a plugin of mine (well, my only plugin so far). As you can see there's a screencast to show the usage. So I basically recorded a GIF of the screen while I was using my plugin with screenkey in execution.

But what if, instead of GIF (or video), I want to use asciinema? For that to work, the keys I press must be show inside the very same terminal that's being recorded.

Hence my question/curiosity.

I thought for a moment I could try to implement such a plugin myself, but the moment after that I realized I have no idea how to catch keystrokes. It looks like I'd need to wrap Vim in an other executable which sees all the keystrokes flow and forwards them to Vim both as keystrokes and as string representing them, the latter needed for Vim to have something that can be echoed in the status line or anywhere else.

(Oh, please, let's add some tag on this site. I have no idea how to tag this question.)

  • Does set showcmd do enough for you? If you type dG for example, to delete until the end of the file, the d will show up on the right side of the statusline, but will disappear when you hit G Commented Oct 2, 2021 at 18:19
  • @ChrisHeithoff no, I'm looking for a solution that shows all the keys as they are hit, just like the non-terminal program screenkey that I linked.
    – Enlico
    Commented Oct 2, 2021 at 18:25
  • Probably no good, easy options here. If you're extremely committed you could try modifying the code for Vim's -w {filename} flag, used by Vimgolf, so it flushes typed characters immediately and submit a patch. :)
    – B Layer
    Commented Oct 3, 2021 at 7:25
  • @BLayer, thanks, that's really a good info. When you say flushes typed characters immediately you mean in contrast to now that it flushes the characters only when one exits Vim? In that case you're approach would be that the plugin would as "was vim opened with -w filename? Keep reading that file and take action to show the last whatever chars in it. Else do nothing", have I understood?
    – Enlico
    Commented Oct 3, 2021 at 8:30
  • @Enlico Yeah, that's pretty much what I envisioned as the path of least resistance. However, if I were in there modifying code to do the quick flush I'd also probably look at how much effort it would take to do something even fancier like redirect the characters to an internal variable or buffer or whatever.
    – B Layer
    Commented Oct 3, 2021 at 19:13


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.