Replace \n with actual new line in Sublime Text

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.


Solution 1:

Turn on Regex Search and Replace (icon most to the left in search and replace bar or shortcut Alt + R)

Find What: \\n
Replace with: \n

Solution 2:

Use Find > Replace, or (Ctrl+H), to open the Find What/Replace With Window, and use Ctrl+Enter to indicate a new line in the Replace With inputbox.

Solution 3:

Fool proof method (no RegEx and Ctrl+Enter didn't work for me as it was just jumping to next Find):

First, select an occurrence of \n and hit Ctrl+H (brings up the Replace... dialogue, also accessible through Find -> Replace... menu). This populates the Find what field.

Go to the end of any line of your file (press End if your keyboard has it) and select the end of line by holding down Shift and pressing (right arrow) EXACTLY once. Then copy-paste this into the Replace with field.

(the animation is for finding true new lines; works the same for replacing them)

enter image description here