Sublime Forum

Joining blocks of text together

#1

I have this text file:

beggining line 1-
beggining line 2-
beggining line 3-
beggining line 4-

end line 1
end line 2
end line 3
end line 4

How can I quickly end up with something like?:
beggining line 1-end line 1
beggining line 2-end line 2
etc

I mean if there is a trick not to have to select one by one each line, copy and paste

0 Likes

#2

Select all of the end line text all at once as one big selection, then select Selection > Split Into Lines from the menu (or press the key that’s listed there). This should convert the selection so that all of the text is selected, but there is a cursor at the end of each line. Once that’s done, copy the text to the clipboard as you normally would.

Now select all of the beginning line text in the same manner as above and split the selection the same way; you should end up with the same as before, with the selection still being present and a cursor at the end of each line.

Press Right to put remove the selection from the text, leaving you with a cursor on each line.

Now anything you type will get typed at all four locations at once, but if you paste, the text that you copied before will be pasted in with one line at each cursor, which will join things up like you want.

Important Note: For this to work, each of the two sets of text need to have the same number of lines in them; if one of them has more or less lines than the other, then the paste will paste every line at every cursor instead of one line per cursor.

You’ll know you did it right if, after splitting the selection into lines the status bar at the bottom of the window says 4 selection regions both times (or however many lines you’re doing this for).

5 Likes

#3

Amazing, thanks!

0 Likes

#4

Here’s another way to do so:

  1. select the text you want to copy.
  2. copy it.
  3. marquee the selection as shown by holding the middle mouse button and dragging a vertical selection.
  4. paste.

dSNCOqZA8P

1 Like