Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what can the dot command repeat, exactly?

Tags:

vim

Vimmers know that . can repeat simple changes. I tried to build a list of what can be repeated or not, but is there a list?

I tried to list what I know to be repeatable: they are all normal-mode commands:

  • Text insertion : a, A, i, I, o, O
  • Text changes involving registers: c, C, d, D, p, gp, P, gP, s, S,x, X
  • Other text changes: J, gJ, r, gr, R, gR, gU, gu, gw, gq, g?, ~, g~, <, >, =
  • Equivalent of these operations in visual mode.
  • Control-operations: C-A, C-X
  • gi will repeat the insertion but at current cursor position, not at last insert position. So it sort of works.

But it does not include:

  • All move and display commands (too numerous to be listed here)
  • All fold commands (z-commands, also numerous)
  • Mark (m)
  • Substitution repeat (&, g&)
  • Colon or Filter command (!, :, Q)
  • Macro recordings or playing (q or @, will repeat last repeatable action done while recording or playing ).
  • Diff put and get (dp, do)
  • Undo (u, U, C-R)
  • Yanks (y)

I know that tpope's repeat plugin can have custom plugins subscribe to the repetition mechanism. But by default, is the above list good?

like image 641
Benoit Avatar asked Sep 24 '12 13:09

Benoit


People also ask

What does DOT do in Vim?

The dot command The dot command is a simple and powerful tool in Vim. It allows repeating the last change by pressing the . (period) key in Normal mode.

How do you repeat a command in Vim?

vim Normal mode commands (Editing) Repeat the Last Change Your cursor will be at position 1 of line 1, and all you need to do to fix the next two lines is press j. twice - that is, j to move down a line and . to repeat the last change, which was the addition of the I .


3 Answers

I believe a change is any command that modifies the current buffer. The . command excludes Ex commands (because that's a different mode that was bolted onto vi in the far history, I guess), and can optionally include yanks.

So for your list, :help change.txt, filtered for Ex commands, is probably the best source.

Note that when a change command cannot be applied (i.e. it beeps), it is also not registered for repeat; the command execution must be successful.

like image 99
Ingo Karkat Avatar answered Oct 18 '22 07:10

Ingo Karkat


some combination with v/V can be "dot" repeated too.

e.g.

Vgq, v/VU or v/Vu

like image 2
Kent Avatar answered Oct 18 '22 06:10

Kent


Tim Pope's repeat.vim can make repeat many more things (including stuff like surround.vim and other must haves).

To repeat a motion, look at , / ; (forward/reverse direction).

To repeat an Ex command, @: is a good key combination

like image 1
sehe Avatar answered Oct 18 '22 07:10

sehe