Learn Vim at your own pace with my self-study Core Vim Course.

Learn more

Learn Vim at your own pace with my self-study Core Vim Course.

Modal editing: undo, redo and repeat

#12

Run time:

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.

Shownotes

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

Comments

Level-up your Vim

Training

Boost your productivity with a Vim training class. Join a public class, or book a private session for your team.

Drew hosted a private Vim session for the shopify team that was one of the best workshops I have ever attended.

John Duff, Director of Engineering at Shopify

Publications

Make yourself a faster and more efficient developer with the help of these publications, including Practical Vim (Pragmatic Bookshelf 2012), which has over 50 five-star reviews on Amazon.

After reading it, I've switched to vim as my default editor on a daily basis with no regrets. ★★★★★

Javier Collado

Learn to use Vim efficiently in your Ruby projects

In association with thoughtbot, one of the most well respected Rails consultancies in the world, I've produced a series of screencasts on how to make navigating your Ruby projects with Vim ultra-efficient. Along the way, you’ll also learn how to make Ruby blocks a first-class text object in Vim. This lets you edit Ruby code at a higher level of abstraction. Available to buy from thoughtbot..