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.

Steven Lu
  • 41,389
  • 58
  • 210
  • 364
  • Related question [A more powerful version of dot (repeat)](http://stackoverflow.com/q/16722566). – glts Jul 31 '13 at 08:20
  • @glts I wrote that... it's similar but requires being prepared by starting recording – Steven Lu Jul 31 '13 at 13:09
  • Just learn to use the [registers](http://stackoverflow.com/questions/1497958/how-to-use-vim-registers?rq=1) 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](http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim?rq=1) – Jake Sellers Aug 01 '13 at 17:46
  • Also, use `"_` "black hole register" to not save anything when deleting. – Jake Sellers Aug 01 '13 at 17:53

2 Answers2

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.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
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?

romainl
  • 186,200
  • 21
  • 280
  • 313
  • 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. – Steven Lu Jul 31 '13 at 13:07
  • . 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. – romainl Jul 31 '13 at 16:02