Step 1 of 4

Searching with Helix

Searching with Helix

Searching is often the fastest way to get where you want in a file, especially when the file is large.

Helix’s search patterns are regular expressions, but plain words work exactly as you’d expect, and plain words are all we’ll use here. This lesson is about how to actually perform a search.

There are two ways to start a search from normal mode:

  • / opens the search prompt and searches forward from the cursor
  • ? opens the same prompt but searches backward

Helix searches as you type, so the editor jumps to the first match before you’ve finished the word. When you’re done, hit Enter to accept the match and return to normal mode, or Escape to abandon the search and go back to where you were. One caution for the checklist below: it ticks off each search as soon as the pattern is typed, before you confirm it, so always finish with Enter. If you press Escape instead, the cursor snaps back to where it started and the next item won’t line up until you redo the search.

Here’s the part that makes search different in Helix: the match you land on is selected. Search doesn’t just move the cursor, it hands you the matched text as a selection, ready for whatever you do next. Watch the highlight as you work through the checklist below.

The editor holds 300 lines of HAYSTACK — too many to scroll through, so search for the only line containing NEEDLE. Once you’ve found it, search backward to hop to the nearest HAYSTACK above you.

  1. Search forward for the needle The only NEEDLE line is 171 lines down, and Helix selects it as soon as you finish typing /NEEDLE.
  2. Search backward for hay The nearest match above you is one line up — Helix hops to it as you type ?HAYSTACK.
Search forward for the needle The only NEEDLE line is 171 lines down, and Helix selects it as soon as you finish typing /NEEDLE.

Next: Search backward for hay

Loading editor…