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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.