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:
a
, A
, i
, I
, o
, O
c
, C
, d
, D
, p
, gp
, P
, gP
, s
, S
,x
, X
J
, gJ
, r
, gr
, R
, gR
, gU
, gu
, gw
, gq
, g?
, ~
, g~
, <
, >
, =
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:
m
)&
, g&
)!
, :
, Q
)q
or @
, will repeat last repeatable action done while recording or playing ).dp
, do
)u
, U
, C-R
)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?
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.
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 .
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.
some combination with v/V can be "dot" repeated too.
e.g.
Vgq, v/VU or v/Vu
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With