Learn Vim / How to Select Text in Vim

How to Select Text in Vim

The answerPress v to start a character-wise selection, stretch it with any motion (w, e, /pattern…), then operate on it (d, y, c).

Try it on a real buffer

Delete “absolutely completely utterly ” — but see it first: move onto “absolutely” (3w), press v to start a selection, stretch it with 3w, pull back one with h, then d.

This plan is absolutely completely utterly doomed.
Visual mode shows you the blast radius first.

Canonical solution: 3w v 3w h d · par: 5 keystrokes (vimgolf rules — every keypress counts).

Why it works

In visual mode every motion stretches the selection, and operators act on what you can see. o swaps which end of the selection you're moving. (A pure operator like d3w is often faster — but seeing the selection builds trust.)

Variations

KeysWhat it does
vcharacter-wise visual mode
Vline-wise visual mode
Ctrl-vblock (column) visual mode
oswap which end of the selection you're moving
gvreselect the last selection

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “See it, then cut it” mission takes about a minute.

Practice free — no signup →

Keep going