Subscribe for free with iTunes, Twitter, or RSS (Ogg or Quicktime).

Vimcasts

Modal editing: undo, redo and repeat

#12

Vim’s modal editing paradigm – the newbie killer – brings tremendous efficiency if only you can learn to work with it, rather than against it. This episode demonstrates how the undo and repeat commands can benefit from spending short bursts of time in insert mode.

Download

OGG 6.6 MB

Quicktime 5.2 MB

In the video, I demonstrate that A plays better with the . command than it’s longhand equivalent: $a. The dot command replays the last edit, but it does not replay motions such as $. The A command compresses the move to line end motion with the append command into a single edit, making the motion implicit, and therefore repeatable with the . command.

The video also demonstrates that c{motion} is a contraction of d{motion}i. Having implicit motion means that the c command also plays well with the dot command.

Implicit motion command Longhand equivalent
c{motion} d{motion}i
C d$a
s xi
S ^C
I ^i
A $a
o $a<CR>

If you are doing a repetitive task, then composing your brush strokes so that they can be replayed with the dot command can save you a lot of time. Learning these ‘implicit motion commands’ will enable you to exploit the dot command to its fullest.

Further reading