Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim Repeat dot (".") command buffer?

Tags:

vim

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.

like image 934
Steven Lu Avatar asked Jul 31 '13 01:07

Steven Lu


2 Answers

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.

like image 136
Ingo Karkat Avatar answered Oct 04 '22 12:10

Ingo Karkat


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?

like image 41
romainl Avatar answered Oct 04 '22 11:10

romainl