Sublime provides search and replaces text in files. It searches files and folders.

Sublime text find and replace

  • Open Sublime Text Editor

  • Open the file from the File Menu or left side project

  • Go To Find Menu > Select Replace Item.

    Or you can use short cut in windows and macOS

    • windows( CTRL +H)
    • macOS ( ⌘ +H)
  • It shows to find a window at the bottom as shown below

Sublime text find and replace

  • It contains Find and Replace items with multiple buttons Find Replace ALL

Find contains text to search in files Replace contains text to replace in find text.

Find and replace text can also be a regular expression or pattern.

How to Replace \n with an actual new line in Sublime Text

Open the Find and Replace window as per the above section.

Input Find type with \\n with Replace type with \n

Finally, Click on the Replace All button or use the shortcut Ctrl + Alt + Enter.

It replaces all characters \n with an actual new line in a file.

Regular expression search in a sublime text editor.

you have a text file

first name: john
first name: ram
first name: eric
first name: andy
first name: mark

you want to replace the word first with full.

Open the Find and Replace window using the Ctrl + H command or from the Find menu.

Please provide regular expression as seen below.

Find: (\w+) first


Replace :full  \1

It replaces with word first with the full word.

you can see the content after replaced in a file

full name: john
full name: ram
full name: eric
full name: andy
full name: mark

It is a simple pattern with basic usage, you can also do this without regular expression.