4

This is a newbie's question, so please be patient if I do not use the right terms.

I know I can use "." to redo my last edit operation. But, is there a way to redo the one just before that?

  • 1
    it doesn't seem like as per unix.stackexchange.com/questions/36719/… .. there might some clever tricks available or to add something to vimrc.. I would recommend to use macro – Sundeep Jul 28 '16 at 5:50
  • 3
    No you can't. Use recordings for that. – romainl Jul 28 '16 at 6:28
  • If "the one just before that" was an ex command, you could have a look at q: (search would be q/). – PhilippFrank Jul 29 '16 at 13:14
5

Unfortunately, this feature is not possible in vim right now. Although it's apparently a popular request, as many people have asked the same thing.

I did find this discussion from two years ago on the vim mailing group. Bram Moolenaar (The founder, inventor, head developer, and current maintainer of vim) chimed in, and mentioned the possibility of a function keyhistory(n) where n is how far back to look.

Plugins having to install a lot of maps to be able to know what was typed before the key that triggers an action is clumsy.

How about Vim keeping a list of the last N typed keys? Suppose there is a function keyhistory(1), where the argument is how far back you look.

I wonder how that would be used in a plugin.

So while theoretically this feature might be eventually implemented, I wouldn't hold your breath. The best alternative would be to use a macro as romainl suggested.

| improve this answer | |

Your Answer

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

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