Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes I share screen shots and clips of vim usage with others. It would be nice to expand on the part of the command line highlighted in this picture:

vim with the current key sequence on the status bar highlighted

I would like some way to make previous key sequences visible as well, such as:

y2w jj f[ p   2d - You can see the key sequences leading up to the current one. I'll elaborate on my wish list at the bottom.

Is something like this is available as a plugin or vim script? The sheer number of scripts available on vim online makes this hard to find by keyword.

Clarification: I added the following section to show what functionality I wanted in case there were many vim plugins that dealt with this. Since it appears as if there are probably few or no plugins to do what I want, this section is largely irrelevant to the question - the question is not how to implement these features, it's whether or not, and where they have already been implemented.

Some features I would hope for (but seem improbable):

  1. Delimit key sequences with a non-keyboard character instead of space, and a different one for the current command, so y2w jj f[ p   2d might become y2w¦jj¦f[¦p » 2d
  2. Replace keys that have a letter alternative with the alternative, such as the right arrow key - ^[[C with the equivalent l. Edit: To clarify, the right arrow key is a valid key in vim, but has no character to represent it (a string like <right arrow> would have to be used), in cases where the l key preforms the same function (most of the time) it should substitute the longer string.
  3. Have previous keystrokes run all the way to the beginning of the line (instead of just one or two), and just have vim's command prompt overwrite it when necessary.
  4. Replace some keystrokes with a more elegant alternative, for example hhhhh with 5h or more impressively d2f) with d% (in the appropriate situation).
share|improve this question
1  
Re 2: <right arrow> and l are not equivalent. See for example, ":help 'whichwrap'". –  garyjohn Nov 30 '11 at 2:47
add comment

1 Answer

Some features I would hope for (but seem improbable):

1. Delimit key sequences with a non-keyboard character instead of space, and a different one for the current command, so y2w jj f[ p   2d might become y2w¦jj¦f[¦p » 2d

First, you have to figure out what you want for yourself. One naive (I'm sure others will come with more elegant methods) method for recording pressed keys in normal mode would be to record a macro (press qa to start, qq to end recording, and view it by :reg). But it's not gonna "split the keys" for you, putting spaces in between because, well ... because you didn't press space while recording it.

If you want to put the contents of register a for example into your text, you can with "ap and then split them up to your liking. After that you can try to join them with something like join(a, "|") or whatever that vertical character is. I'm not sure from here.

2. Replace keys that have a letter alternative with the alternative, such as the right arrow key - ^[[C with the equivalent l.

This requires some higher logic, since there are often multiple ways to accomplish the same thing. What is the "alternative"?

3. Have previous keystrokes run all the way to the beginning of the line (instead of just one or two), and just have vim's command prompt overwrite it when necessary.

Now that I think about it, have you tried this maybe with a keylogger? It seems it would be better than my first suggestion here, expecially if you're aiming at recording screencasts.

4. Replace some keystrokes with a more elegant alternative, for example hhhhh with 5h or more impressively d2f) with d% (in the appropriate situation).

Difficult. 5h is just Vim's way of saving you the trouble of pressing hhhhh.

EDIT: Just to add, if you're doing all this for the purposes of recording a screencast or an educational video DemoCreator can record keystrokes and present them on screen, as you're pressing them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.