Inspect and reuse a search

0 of 3

The technique

Your textVim mode: Normal
Find the next two ready lines. Before: first ready / second ready / third ready. After: first ready / second ready / third ready.

* searches for the word under the cursor. n repeats the search in the same direction.

Keys in this lesson

n
Next match.
N
Previous match.
*
Search for the word under the cursor.
#
The same, backward.

Before this lesson: Search for a destination.

More about this lesson

Repeat a search, reverse it, and search for whole words only.

n repeats your last search in the same direction and N goes the other way. After ?, n still searches backward. * searches forward for the whole word under the cursor and # searches backward. /cat can match catalog, but * on cat skips it. Check each match before you edit, in case it's one to leave alone.

Example

With three “ready” lines, /ready then Enter reaches the next one and n the one after that. N goes back to the previous match. Searching only moves the cursor.

Use Start over to try again.

Guides on this topic

Exercise 1 of 3

0keys

par 2

Put the cursor on the subtotal call in total.

Your textVim mode: Normal

Move the cursor here

12    return subtotal(lines) + vat(lines) + shipping;

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.