Step 3 of 4

Searching for the selection

Searching for the selection

Some words are awkward to type — long variable names in code, for example. When the word you want to find is already in front of you, Helix lets you search for it without typing a letter of it.

In normal mode, * takes whatever is currently selected and makes it the search pattern. It doesn’t move the cursor on its own; it just sets up the search, so follow it with n or N to jump to the next or previous instance.

Because * uses the selection, you need to select the word first. A plain cursor selects only one character, so pressing * with nothing selected searches for that single character, which is rarely what you want. Select the word with e (or w, or any of the selection commands from earlier lessons), then press *.

Work through the checklist below. HaRd_to_Type_Word appears three times in the file and the cursor starts on the first one. Select it, set it as the search pattern, and hop to the other two.

  1. Select the word The cursor starts on line 1 at the start of the word — press e to select to its end.
  2. Make the selection the search pattern Nothing moves yet, but the search is now set — press *.
  3. Jump to the next instance The second instance is 87 lines down — press n.
  4. And the last One more hop lands on the third and final instance — press n.
Select the word The cursor starts on line 1 at the start of the word — press e to select to its end.

Next: Make the selection the search pattern

Loading editor…