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 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
- It contains
Replaceitems with multiple buttons Find Replace ALL
Find contains text to search in a 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 Find and Replace window as per the above section.
Find type with
Replace type with
Finally, Click on 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
Open Find and Replace window using 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
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.