Skip to content

Search and Replace

Sublime Text features two main types of search:

Both support regular expressions, a powerful tool for searching and replacing text.

Single File

Searching

Keyboard shortcuts related to the search panel:

DescriptionShortcut
Open search panelCtrl F
Toggle regular expressionsAlt R
Toggle case sensitivityAlt C
Toggle exact matchAlt W
Find next
Find previous 
Find allAlt 

Keyboard shortcuts related to the incremental search panel:

DescriptionShortcut
Open incremental search panelCtrl I
Toggle regular expressionsAlt R
Toggle case sensitivityAlt C
Toggle exact matchAlt W
Find next
Find previous 
Find allAlt 

The only difference between this panel and the regular search panel lies in the behavior of the key. In incremental searches, it will select the next match in the file and dismiss the search panel for you. Choosing between this panel or the regular search panel is a matter of preference.

Replacing Text

Keyboard shortcuts related to the replace panel:

DescriptionShortcut
Open replace panelCtrl H
Replace nextCtrl  H
Replace allCtrl Alt 

Tips

Other Ways of Searching in Files

Goto Anything provides the # operator to search in the filtered file.

These key bindings work when the search panel is hidden:

DescriptionShortcut
Search forward using most recent patternF3
Search backwards using most recent pattern F3
Select all matches using most recent patternAlt F3

You can also perform searches based on the current selection:

DescriptionShortcut
Search using current selectionCtrl E
Replace using current selectionCtrl  E

You can type in multiline search patterns into search panels. To enter newline characters, press Ctrl .

Mutiline Replace

Note that search panels are resizable too.

Multiple Files

Searching

Keyboard shortcuts related to Find in Files:

DescriptionShortcut
Open Find in FilesCtrl  F
Toggle regular expressionsAlt R
Toggle case sensitivityAlt C
Toggle exact matchesAlt W
Find nextEnter

Search Scope

The Where field in Find in Files limits the search scope. You can define scopes in several ways:

  • Adding individual directories (Unix-style paths, even on Windows)
  • Adding/excluding files based on wildcards
  • Adding symbolic locations (<open folders>, <open files>...)

It is also possible to combine these filters using commas; for example:

Search Patterns

Press the ... button in the search panel to display a menu containing scope options.

Results Format

In the search panel, you can customize how results are displayed. These are the available options:

  • Show in separate view
  • Show context

Search Results

If the search yields matches, you can move through the sequence using the following key bindings:

DescriptionShortcut
Next matchF4
Previous match F4
Open match

You can also double-click on lines with a match.

Regular Expressions

Regular Expressions find complex patterns in text. To take full advantage of the search and replace facilities in Sublime Text, you should at least learn the basics of regular expressions. In this guide we won't explain how to use regular expressions.

The term regular expression is usually shortened to regexp or regex.

This is how a regex might look:

(?:Sw|P)i(?:tch|s{2})\s(?:it\s)?of{2}!

To use regular expressions in Sublime Text, you first need to activate them in the various search panels. Otherwise, search terms will be interpreted literally.

Search and Replace

Sublime Text uses the Perl Compatible Regular Expressions (PCRE) engine from the Boost library.

See Also

Boost library documentation for regular expressions : Documentation on regular expressions.

Boost library documentation for format strings : Documentation on format strings. Note that Sublime Text additionally interprets \\{n} as ${n}.