Finding and replacing
The find bar
Search > Find… (Ctrl+F) opens the find bar above the text. If you had text selected, it's already filled in. Ettin Edit searches as you type, highlights every match, and shows 3 of 17 so you know where you are.
| In the find bar | What it does |
|---|---|
| Enter / Shift+Enter | Next / previous match |
| ↓ / ↑ | Next / previous match (also F3 / Shift+F3 from anywhere) |
| Aa | Match case |
| W | Whole words only |
| \n | Extended: \n, \t, \xNN and the like mean those characters |
| .* | Regular expression |
| … | More: Wrap around, Find All, Select All Matches, Mark All |
| Esc or × | Close the find bar |
With Wrap around on (the default), searching past the last match starts again at the top.
Find Selected Next (Ctrl+F3) and Find Selected Previous (Ctrl+Shift+F3) search for the selected text, or the word at the caret, without opening the find bar.
Replacing
Search > Replace… (Ctrl+H), or the ⏵ arrow at the left of the find bar, adds a second row:
- Replace replaces the current match and moves to the next. Pressing Enter in the replace box does the same.
- Replace All replaces every match as one undo step. It stays fast on big files: 282,000 replacements in a 50 MB file take about a second.
- In selection limits Replace All to the selected text. It's turned on for you when you open the bar with several lines selected.
Leave the replace box empty to delete what you searched for: Replace All
with an empty box removes every match. This works in all three modes, so
Extended \r\n or the regular expression \r\n with an empty
replacement joins every line into one.
Line breaks
Ettin Edit keeps every line break as one character while you edit, and
writes the tab's own line ending (shown in the status bar) when it saves. So
in Extended mode and in regular expressions, \r\n, \r and \n all
find a line break, whether the file uses Windows (CR LF), Unix (LF) or old
Mac (CR) line endings. A match on a line break is highlighted just past the
end of its line.
In a regular expression, an optional \r (as in \r?\n) finds nothing on
its own, so \r?\n still finds exactly one line break. To change the line
endings a file is saved with, click the line ending in the status bar (see
Line endings).
Extended mode (\n, \t, \xNN)
Turn on \n to search for characters you can't type in the find box,
without writing a regular expression. Everything else in the box is plain
text, so . and * still mean themselves. Extended mode and regular
expressions are two ways of reading the box, so turning one on turns the
other off. The same escapes work in the replacement.
| Write | To mean |
|---|---|
\n | A line break |
\r | A line break too: Ettin Edit keeps every line break as one character and writes the tab's own line ending when it saves, so \r\n, \r and \n all mean a line break |
\t | A tab |
\0 | The NUL character |
\\ | A backslash |
\xNN | The character with hex code NN, such as \x41 for A |
\uNNNN or \u{N…} | Any Unicode character, such as \u00E9 for é or \u{1F600} for 😀 |
\dNNN | The character with decimal code NNN (up to 255), such as \d065 |
\oNNN | The character with octal code NNN (up to 377), such as \o101 |
\bNNNNNNNN | The character with binary code NNNNNNNN, such as \b01000001 |
A backslash followed by anything else is searched for as it is.
For example, find ,\t and replace with ;\n to turn every comma followed
by a tab into a semicolon and a new line. Find in Files has an Extended
box that works the same way.
Regular expressions
Turn on .* to search with a regular expression. Ettin Edit uses the
syntax of the Rust regex library, which is close to Perl's and Python's,
except that look-around ((?=…), (?<=…)) and back-references inside the
pattern aren't supported.
| Pattern | Matches |
|---|---|
\d+ | One or more digits |
^\s+$ | A line holding only spaces or tabs (^ and $ are line starts and ends) |
colou?r | color or colour |
(\w+)@(\w+)\.com | An address such as ann@example.com, with two groups |
(?<year>\d{4})-(?<month>\d\d) | A date, with named groups |
(?s)begin.*?end | begin to the nearest end, across lines |
In the replacement:
| Write | To insert |
|---|---|
$1 or \1 | The first group ($2, \2 and so on for the others) |
${name} | A named group |
$0 | The whole match |
\n, \t | A line break, a tab (\r and \r\n are a line break too) |
$$ | A dollar sign |
\\ | A backslash |
For example, find (\w+), (\w+) and replace with $2 $1 to turn
Lovelace, Ada into Ada Lovelace.
Finding everything at once
These are in the Search menu and the find bar's … menu:
- Find All in Current Document lists every matching line in the results panel at the bottom.
- Find All in Open Tabs does the same for every tab.
- Select All Matches puts a caret on every match, so you can edit them all at once (see multiple carets).
- Mark All highlights every match in a different colour that stays after you close the find bar. Mark All and Bookmark Lines also bookmarks each line with a match. Clear All Marks removes the highlights.
Find in Files
Search > Find in Files… (Ctrl+Shift+F) searches every file in a folder:
- Find what: the text or regular expression, with the same Match case, Whole word and Regular expression options as the find bar.
- Folder: where to look. Browse… picks one.
- Files: which files, as patterns separated by spaces or semicolons, such
as
*.rs *.toml. Start a pattern with!to leave those files out, for example*.js !*.min.js. Leave it empty for every file. - Include subfolders and Include hidden files and folders.
The search runs in the background, so you can keep working; Stop ends it early. Binary files are skipped.
You can also start Find in Files from the folder workspace: right-click a folder and choose Find in Files Here….
The results panel
Find All and Find in Files show their results in a panel below the text, grouped by file, with the matching words highlighted.
- Click a line to jump to it; the file opens if it isn't open yet.
- Click a file's heading to fold its results away; Collapse All and Expand All do every file.
- × closes the panel.
Go to Line
Search > Go to Line… (Ctrl+G), or a click on Ln, Col in the
status bar, asks for a line number. Type 120 to go to line 120, or
120:15 for line 120, column 15.
Bookmarks
Bookmarks mark lines you want to come back to. A bookmarked line shows a marker in the gutter.
| Command (Search > Bookmark) | Shortcut |
|---|---|
| Toggle Bookmark (or click the gutter) | Ctrl+F2 |
| Next Bookmark | F2 |
| Previous Bookmark | Shift+F2 |
| Clear All Bookmarks |
The same submenu works on the bookmarked lines as a group: Cut, Copy or Remove Bookmarked Lines, Remove Unbookmarked Lines (keep only the bookmarked ones), and Inverse Bookmarks.
Together with Mark All and Bookmark Lines, that gives a quick way to pull out every line that matches something: mark them, then Copy Bookmarked Lines and paste them into a new tab.