Step 7 of 7

5. Visual Mode

Selecting text objects

Manually selecting a text region is useful for making small, precise edits. But sometimes, we’re interested in the bigger picture. For example, we might want to visually select an entire sentence, paragraph, or block of code.

Visual mode has key maps for this. From any of the visual mode variants, you can use:

  • is to expand your visual selection to capture the current sentence
  • ip to expand your visual selection to capture the current paragraph
  • i" to expand your visual selection to capture the currently quoted string (anything within "")
  • i{ to expand your visual selection to capture the current block of code (anything within {})

There are similar mappings for (, [, and so forth, too.

So to immediately select an entire sentence, you can type vis. Or, to immediately select an entire paragraph, it’s vip.

Work through the checklist below, expanding your selection with each text object in turn.

  1. Select the current sentence Put the cursor inside the first paragraph and type vis.
  2. Expand to the whole paragraph With the selection still active, type ip.
  3. Select inside the quotes Press Escape to drop the selection, move into the quoted string, then type vi".
  4. Select inside the code block Press Escape again, move anywhere inside the {} block, then type vi{.
Select the current sentence Put the cursor inside the first paragraph and type vis.

Next: Expand to the whole paragraph

Loading editor…