Sublime Forum

Regex - Insert a new line

#1

hello. I have this line.

1 2 3 4 5 6 7

And if I want to look like this

1
2
3
4
5
6
7

I use this regex:

Find: (select all spaces between words)
[^\S\r\n]+

Replace by:
\r (or \n)


BUT, how can I add one single new line after “1 2 3 4 5 6 7” ?

0 Likes

#2

Find: (.)$
Replace by: $1\n

This will replace any character at the end of the line by itself followed by a new line.

0 Likes

#3

This is much better. Will insert a new line after the line that contains a certain Words.

Find: (?<=WORDS_IN_A_CERTAIN_LINE)(.*$)
Replace By: $1\n

0 Likes