Reputation: 12003
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.
Upvotes: 573
Views: 482813
Reputation: 17
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
Upvotes: 1
Reputation: 586
The easiest way, you can copy the newline (copy empty 2 line in text editor) then paste on replace with.
Upvotes: 8
Reputation: 47
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.
Upvotes: 2
Reputation: 1290
For Windows line endings:
(Turn on regex - Alt+R)
Find: \\r\\n
Replace: \r\n
Upvotes: 9
Reputation: 4921
On Mac, Shift+CMD+F for search and replace. Search for \n
and replace with Shift+Enter.
Upvotes: 7
Reputation: 231
\n
in find input box\n
in the text with the cursor\n
with the New LineUpvotes: 14
Reputation: 11597
None of the above worked for me in Sublime Text 2 on Windows.
I did this:
By selecting before hitting Ctrl+H it uses that as the character to be replaced.
Upvotes: 6
Reputation: 211
In Sublime Text (with shortcuts on Mac):
Highlight the text that you want to search to apply Find & Replace
Go to Menu > Find > Replace... (Keyboard Shortcut: Alt + Command + F)
In the Find & Replace tool, enable Regular Expression by clicking on the button which looks like [.*] (Keyboard Shortcut: Alt + Command + R)
In Find What, type: \\n
Note: The additional \
escapes the Regular Expression syntax when searched.
In Replace With, type: \n
Click on the 'Replace All' button (Keyboard Shortcut: Ctrl + Alt + Enter)
Your literal text \n
will then turn into an actual line break.
Upvotes: 21
Reputation: 411
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)
Upvotes: 29
Reputation: 11857
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
Upvotes: 997
Reputation: 1012
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.
Upvotes: 12
Reputation: 4598
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.
Upvotes: 362
Reputation: 3990
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)
Upvotes: 68