Edit a rectangle

0 of 1

The technique

Your textVim mode: Normal
Put - in front of all three lines. Before: one / two / three. After: - one / - two / - three.

The text appears on every selected line when you press Esc. gv then $A would add text to the end of the same lines.

Keys in this lesson

Ctrl-v
Select a block of columns.
Ctrl-v…I
Type at the left edge of every selected line, then Esc.
Ctrl-v…$A
Type at the end of every selected line, then Esc.

Before this lesson: Visual selection and insertion.

More about this lesson

Edit a column of text on several lines at once. The change shows up when you press Esc.

Ctrl-v selects a rectangle. I types at its left edge and A at its right edge, and the text appears on every line when you press Esc. Press $ before A to add text at the real end of each line, even when the lines are different lengths. gv selects the same block again, so you can add to the start and then the end. If your browser takes over Ctrl-v, use Keyboard check.

Example

Select the first column of three notes with Ctrl-v then 2j. Press I, type a bullet and a space, then press Esc to add them to all three lines.

Use Start over to try again.

Guides on this topic

Exercise 1 of 1

0keys

par 21

The four lines run together as one paragraph. Make each of them a list item, <li> at the start and </li> at the end.

Your textVim mode: Normal

Make it look like this

// Shown under the price on every product page.
export function DeliveryInfo() {
  return (
    <ul className="delivery-info">
      <li>Free delivery on orders over 50 euros</li>
      <li>Sent within two working days</li>
      <li>Free returns for 30 days</li>
      <li>Pay later with Klarna</li>
    </ul>
  );
}

Yours

Par

Keyboard shortcuts
Ctrl+Enter
Check the result
Ctrl+Alt+U
Undo the last change
Ctrl+Alt+H
Show the next hint
Ctrl+Alt+R
Start the exercise over
Ctrl+Alt+P
Previous exercise
Ctrl+Alt+N
Next exercise
Ctrl+Alt+K⌃⌥K
Show the keyboard shortcuts
Ctrl+Alt+F⌃⌥F
Turn focus mode on or off
Ctrl+Alt+S⌃⌥S
Open the editor settings
Enter
Go on to the next step after you finish

The Ctrl+Alt shortcuts don't clash with Vim's own keys. On a Mac, use Control and Option.