2

I don't know how to make any vimscript I'm writing or running aware of what my pending command is!

Specifically: When I hit ^W in preparation to change the window I'm selecting, I'd like to have my statusbar reflect that.

  • You can check the value of the option in an expression using &showcmd, but that just tells you whether its on or off—afaik there’s no way to tell what’s already been typed. (You could create a mapping.. i might have an idea for you there. ) – D. Ben Knoble Aug 8 at 3:37
  • A mapping would work to add state, and maybe a BufEnter autocmd to remove state would work... I don’t love how hacky that is though :P – Ari Sweedler Aug 8 at 3:53
  • 1
    No, i would map control w to do what it normally does plus whatever you want to do – D. Ben Knoble Aug 8 at 3:55
  • Very similar: Can I see the history of key presses in normal mode? and showcmd on first line instead of last line – last time I looked at this the answer was "no, this isn't possible" as far as I could figure out (see my answer on that last one). – Martin Tournoij Aug 10 at 22:12
  • 1
    Like you said, a mapping could work, but I can't really think of a good way to clear the state without redefining a lot of mappings. The way ^W<key> works internally btw is that ^W is mapped and then it has a long switch (second_key) { ... } for the second key press to call the correct functionality. It's all pretty hard-coded in a non-generic way. – Martin Tournoij Aug 10 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.