Replace \n with actual new line in Sublime Text

Viewed 399333

How can I replace \n in Sublime Text with real in-editor displayed new line so:

foo\nbar

becomes:

foo
bar

in the editor when I view the file in it.

13 Answers

On Windows, Sublime text,

You press Ctrl + H to replace \n by a new line created by Ctrl + Enter.

Replace : \n

By : (press Ctrl + Enter)

What I did is simple and straightforward.

Enter Space or \n or whatever you want to find to Find.

Then hit Find All at right bottom corner, this will select all results.

Then hit enter on your keyboard and it will break all selected into new lines.

  1. Open Find and Replace Option ( Ctrl + Alt + F in Mac )
  2. Type \n in find input box
  3. Click on Find All button, This will select all the \n in the text with the cursor
  4. Now press Enter, this will replace \n with the New Line

On Mac, Shift+CMD+F for search and replace. Search for \n and replace with Shift+Enter.

For Windows line endings:

(Turn on regex - Alt+R)

Find: \\r\\n

Replace: \r\n

illustration

The easiest way, you can copy the newline (copy empty 2 line in text editor) then paste on replace with.

On MAC:

Step 1: Alt + Cmd + F . At the bottom, a window appears
Step 2: Enable Regular Expression. Left side on the window, looks like .*
Step 3: Enter text to you want to find in the Find input field
Step 4: Enter replace text in the Replace input field
Step 5: Click on Replace All - Right bottom.

replace field

ctrl+h

sample : type: </> replace: \n

down below , find button - change to ALT+R you see changed eFFect in color , better to use sample

nice feature

Related