Sublime Forum

Your help is needed and appreciated! How can I merge 2 lines

#1

Hi all,

I would be very grateful if someone can help. I would like to merge lines at ones , instead of manually (see example below)
From this
1
Hi
2
How are you
3
What are you doing?

to this
1 Hi
2 How are you
3 what are you doing?

0 Likes

#2

I am not sure exactly what you mean by “lines at ones.”

This is a way to join two lines in which the first line contains only one digit, and nothing more. Go to Find -> Replace, and insert ^(\d)$\n in the Find field, and $1 in the Replace field. Then, click on Replace All.

To join lines in which the first line contains a number, independent of the number of digits, use ^(\d+)$\n in the Find field, and $1 in the Replace field. Then, click on Replace All.

0 Likes

#3

Hi Rcopat,

Appreciate your response!

I will explain it in another example.

I would like to turn this text:

Bob
How are you doing?
Dave
I am good. What about you?
Bob
Also good.

Into 2 column text:
Bob How are you doing?
Dave I am good.What about you?
Bob Also good

I will export the text in excel and would like to have the names in column A for example and their lines in the other column (B).

Right now I am Manually I am deleting the space between the 2 lines (name and phrases) but i was wondering if there is a better way to do it (less time consuming)

Appreciate your help!

Have a great weekend

0 Likes

#4

The solution to your problem depends on whether there is a pattern in your file.

I will assume that every odd line number contains the name of a speaker, and every even line number contains the sentence(s) that he/she speaks. Then, press Ctrl + F, turn on regular expressions (Alt + R), insert .*\n.*\n in the Find field, and click on Find All. Press , End, Delete and then Tab. Now you can copy and paste the text into Excel. Excel should recognize the Tab as a column separator.

0 Likes

#5

Hi rcopat,

Thank you very much! Appreciate it!

I wish you a great year and all the best

0 Likes