editor

Docs › Writing helpers

Find and replace

Ctrl+F to find in the content, Ctrl+H to replace.

Find words in a long post, or replace them all at once. Inside the editor, Ctrl+F opens find and Ctrl+H adds the replace row. A find bar opens at the top of the editor instead of the browser's page search.

Try it

Code for this demo

createEditor('#editor', {
  toolbar: 'findReplace | undo redo',
});

How it works

  • Open it with text selected (one line, under 100 characters) and that text is the search.
  • All matches are painted, the current one stronger, with a count like 3/7. It starts at the first match after the caret.
  • In the find box Enter is next and Shift+Enter previous. In the replace box Enter replaces the current match. Esc closes.
  • Match case tells upper and lower case apart.
  • Replace all is one undo step.
  • A match never spans paragraphs; within one it may cross formatting such as bold.

The toolbar item is findReplace. In the board and full presets it is in the ⋯ more menu; the shortcuts work without it. Find works in read-only mode, replace does not.

From code

editor.exec('findReplace'); // find
editor.exec('replace');     // with the replace row

Options

NameTypeDefaultDescription
findReplacetoolbar item—Open the find and replace bar
Ctrl+F / Ctrl+Hshortcut—Find / replace (⌘ on macOS)