Northern Commander

Finding and replacing

In the editor, find text or a pattern, replace it one match at a time or everywhere at once, and go straight to a line by its number.

At a glance

KeyAction
F7Find and replace…
F3Find next
⇧F3Find the one before
⌘GGo to…

Finding

F7, or ⌘F, asks what to look for, and what to put in its place if anything is to be replaced. It starts with the text you have marked, if it is on a single line, and with your last search otherwise.

One dialog for finding and replacing: which it does is the button.
Find
What to look for. Its list of earlier searches is the one every search in a file shares, the viewer’s included.
Replace with
What goes in place of a match. As typed, unless Regular expression is ticked: then $1 is what the pattern’s first group matched, ${name} a named group, $0 the whole match and $$ a dollar sign. Its list of earlier replacements is its own.
Match case
Capitals and small letters differ. Off, they match each other.
Regular expression
The pattern is a regular expression rather than the text itself. One that cannot be used says why under the boxes, and grays every button but Cancel.
Find, Back
The next match after the cursor, or the one before it. Enter is Find.
Replace
Puts the replacement in place of the match that is marked, and marks the next one — see below.
All
Replaces every match in the file.

What is found is marked, the way a block is, so any key that acts on a block acts on it — typing replaces it, F5 copies it.

  • F3 and ⇧F3 look again without asking. They are gray until you have searched in this file.
  • Looking again starts from the far side of the match that is marked, so it moves on.
  • The search goes round: past the end of the file it carries on from the top. The header says not found only when there is no match anywhere.
  • A match that was out of sight is shown two lines below the top of the window. One already in sight stays where it is.
  • A match never runs past the end of a line.
  • A match inside a fold opens it.

Replacing

One at a time. Find the first match, then press F7 and Replace: the match that is marked is replaced and the next one marked. The dialog opens on what you asked last time, so it is the same two presses for each. Where what is marked is not a match, Replace only finds the next.

Everywhere. All replaces every match in the file at once, and the header says how many — 12 replaced. However many there were, it is one step of undo.

  • An empty Replace with deletes what it replaces.
  • Without Regular expression the replacement goes in as it is written, and $1 is the two characters $1.
  • With it, the replacement is read the way .NET reads one. A $ that names no group stays a $. Searching (\w+) (\w+) and replacing with $2, $1 turns john smith into smith, john.
  • A file that cannot be written back is not changed.

Going to a line

⌘G asks for a line by its number:

Line, of …
How many lines the file has is in the label. The box starts on the line the cursor is on, marked, so what you type replaces it. Go stays gray until it is a line the file has.

The cursor goes to the start of that line, opening a fold if the line is inside one. To go to a matching bracket instead, see brackets.