13

I really like the behavior of YankRing, which lets me access the last several things I've yanked or deleted or changed without thinking.

However a complementary feature like this is completely missing for the . repeat command, most often when I type something I really want to repeat, then accidentally overwriting that edit by pressing x to clean something up.

Often it's possible to get back some time still by visual-mode yanking what I just typed, but this is not ideal.

It should be really easy to remember the past few commands.

The question is how possible is it to extract from Vim the representation of the last command contained in whatever stores what . will do before it gets blown away?

If it is as I fear, the only way is to get a plugin to bind to every single command that could edit something, and instrument it in such a way as to store our own repeat-buffer. This is really not practical because I can already imagine how many other plugins that will break. But, I would still really really want this feature if it is possible in any way.

4
  • Related question A more powerful version of dot (repeat). Commented Jul 31, 2013 at 8:20
  • @glts I wrote that... it's similar but requires being prepared by starting recording Commented Jul 31, 2013 at 13:09
  • Just learn to use the registers and other built-vim functionality imo. So many plugins that "fix" things that don't need to be fixed. Dot operator works perfectly with the registers. For example, you can "qp to paste the q register and repeat with ., but any edits such as x will not change what you have saved in any non-default registers. Another great post to read here Commented Aug 1, 2013 at 17:46
  • Also, use "_ "black hole register" to not save anything when deleting. Commented Aug 1, 2013 at 17:53

2 Answers 2

3

Unfortunately, there's no way to get and replay the command behind the . command. The only workaround is to be perpetually in macro recording mode, and use the macro register as a replacement for the . command.

This tactic is employed by the RepeatLast plugin, which might offer what you want.

Sign up to request clarification or add additional context in comments.

Comments

1

Keyword completion and/or ctrl-a in insert mode should cover your needs.

A more yankring-like solution should be possible but, as you say, probably a little too intrusive. Did you look on vim.org by yourself before asking others to do it for you?

2 Comments

Yeah, I mean there isn't even a way Vim provides to figure out what the . will do. I was really hoping someone has a source patch to expose it with a command.
. repeats your last change. That's quite simple, really. The dot command is not really designed to execute series of commands from long ago so, practically, you never have to guess what it's going to do. If you want more longterm solutions use macros and mappings.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.