Tip 12Combine and Conquer

Much of Vim’s power stems from the way that operators and motions can be combined. In this tip, we’ll look at how this works and consider the implications.

Operator + Motion = Action

The d{motion} command can operate on a single character (dl), a complete word (daw), or an entire paragraph (dap). Its reach is defined by the motion. The same goes for c{motion}, y{motion}, and a handful of others. Collectively, these commands are called operators. You can find the complete list by looking up operator, while Table 2, ​Vim’s Operator Commands, summarizes some of the more common ones.

Table 2. Vim’s Operator Commands
TriggerEffect

c

Change

d

Delete

y

Yank into register

g~

Swap case

gu

Make lowercase

gU

Make uppercase

>

Shift right ...

Get Practical Vim, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.