0

I often find that I press the wrong set of keys but I can't figure out what I went wrong with.

In other words, a fat finger. However I don't know if it's a fat finger or not just from the output, a lot of the time yes I could figure it out, but instead I prefer Vim to tell me where I went wrong.

What I would like is to have something in my statusline that outputs the last set of valid key presses.

No showcmd does not work for my needs, that only outputs what I'm currently typing, tells me what Vim knows from me currently.

What I need is to know what Vim knew from me the last time I pressed keys.

So for examples, what I pressed on the left and what I want this addition in the statusline to tell me on the right.

j            j
jjjjj        j
5j           5j
4jj          j
Isome text   I
Aoh yeah     A
.            (Whatever the dot key just repeated)

Etc. You get the idea. :)

What would be a simple way to achieve this? It's probably some obscure variable that Vim keeps track of and I'm just not aware of it.

Any help is appreciated. :)

greduan
  • 4,770
  • 6
  • 45
  • 73
  • 1
    `What would be a simple way to achieve this?` `No simple way`. If you pressed some keys by mistake, from the result you would know what you 've pressed. next time, pay attention on that. I don't think vim could do it for you, and nobody would write a plugin like that either... – Kent Oct 23 '13 at 20:05
  • 1
    See also http://stackoverflow.com/questions/8928070 – Matthew Strawbridge Oct 23 '13 at 20:12

1 Answers1

2

No, there's no built-in way to tell you if what you just typed is wrong and only a subset of what you type is recorded with some persistence (Ex commands, searches but not normal mode commands or inserts).

Recording everything you type is "easy" or rather "doable" with a key logger. Making sense of the content of the log (supposing we are able to decide where a command starts and where it ends) is another matter entirely. jjjj, 4j, /foo<CR>, 56G, or even using the mouse are all perfectly valid ways to move the cursor to foo and AFAIK, no one has ever written a program able to tell you which one of the method above is the most "valid".

So, in the meantime, you are left with your brain and how good it is at focusing on a given task and at manipulating abstract concepts: pay attention to what you do, identify bottlenecks and look for possible improvements.

From Seven habits of effective text editing:

  1. While you are editing, keep an eye out for actions you repeat and/or spend quite a bit of time on.

  2. Find out if there is an editor command that will do this action quicker. Read the documentation, ask a friend, or look at how others do this.

  3. Train using the command. Do this until your fingers type it without thinking.

romainl
  • 186,200
  • 21
  • 280
  • 313