Sublime Text find and replace

Learn how to find and replace text quickly and easily in Sublime Text with an example.

Sublime Text Find and Replace

Sublime Text's powerful find and replace feature is one of its most popular features. It allows you to quickly search for and replace words or phrases within your document. It also has multiple options for customizing your search, including matching case, regular expressions, and whole words.

To open the Find & Replace window, press Ctrl + F (or Cmd + F on Mac) or select Find > Find… from the menu. To open the Replace window, press Alt + F (or Cmd + Alt + F on Mac) or select Find > Replace… from the menu.

In the Find & Replace window, you can type in the word or phrase you want to search for. You can also customize your search by selecting the checkboxes at the bottom of the window. If you select the "Regular expression" checkbox, you can use regex to search for patterns in your document. If you select the "Match case" checkbox, the search will be case sensitive. If you select the "Whole word" checkbox, the search will only match words that are surrounded by non-word characters.

// Search for a word
var searchString = "Hello";

// Replace the word with this
var replaceString = "Goodbye";

// Find and replace
var newString = oldString.replace(searchString, replaceString);

The Find & Replace window also has a few other useful options. You can click on the "Find All" button to search for all matches in your document. You can also click on the "Replace All" button to replace all of the matches with the replacement word or phrase. Finally, you can click on the "Preserve Case" checkbox to keep the case of the replaced words the same as the original word.

Sublime Text's Find & Replace feature is a powerful and versatile tool. With the right settings, you can quickly and easily search for and replace words and phrases in your document.

Answers (0)