36

How do I cut and paste a column of text in Sublime text 3 -

For example:

File A

Alpha
Beta
Gamma
Delta

File B

AAA
BB
CCCCC

I want to end up with file B having

Alpha AAA
Beta  BB
Gamma CCCCC
Delta
Mike
  • 507
  • 1
  • 4
  • 8

7 Answers7

25

Select and copy the lines on File B you want to copy. Move to File A, select the lines you wish to copy into. Press Ctrl+Shift+L to split your selection into a multiple line selection, move the cursors to wherever you want and paste.

The one limitation of this is that the cursors will keep their relative positions, you may not want this. Perhaps you want them all to remain in a fixed column.

Hold down the middle mouse button and drag to select one or many columns of text, again press Ctrl+Shift+L to split your selection into lines and proceed as before.

owl
  • 424
18

First, select the lines in File B that you want copied. Note the number X of lines (this should be displayed on the bottom of your screen).

Second, select the first X lines of File A so that there is a cursor at the end. To do this:

  • move your cursor to the end of the first line,
  • go up to the Selection menu, and use the shortcut for Add Next Line until X lines are selected. On OSX, its controlshiftdown.

In this example, there will be 3 cursors at the end of File A that look like this:

Alpha|
Beta|
Gamma|
Delta

Finally, press tab once, then paste your lines. You should have the results you want.

Because of the way this is done, its easier to paste into File A. However, if you really want to paste into file B or some other file, just copy the lines in File A into the target file before you start, and do the same process.

Basj
  • 2,143
LMNOP
  • 332
12

Steps:

  1. Go to File B, and enter multi-selection (++L OR Ctrl+shift+ L) on

    AAA
    BB
    CCCCC
    

    making sure everything is selected, and not just parts of the lines you want to copy.

  2. While in multi-selection mode, copy (+C OR Ctrl+C)

    AAA|
    BB|
    CCCCC|
    
  3. Go to File A, and make sure to enter multi-selection on exactly the same number of lines (in this case 3).

    Alpha|
    Beta|
    Gamma|
    Delta
    
  4. Paste (+V OR Ctrl+V) & voilà :)

Let me know if this works for you!

antoine
  • 143
Q8i
  • 221
2

Little late but found this package on SublimeText forum called Paste as Column. You can find it in Package Control.

Works well, at least enough to get the data in the right area

RE: Original Forum page: https://www.sublimetext.com/forum/viewtopic.php?f=4&t=10008

Tab
  • 121
0

go to file B -> do a multi line select, which on macos can be done by using option and mouse press and drag.

go to file A -> do a multi line select and paste.

What was confusing to me in the previous answers was, how to do the selection in the file B. I was doing a cmd+A, selecting everything.

So the only thing out of the obvious here is you have to do a multi line select in the file B.

anurag
  • 1
0

Linux:

Step1
Copy the text you want to insert.

Step2(the most important)
hold RighMouseButton+Shift
and move the mouse inside the text. You will be able to select a column or columns.

Step3
Ctrl+V

Alex
  • 150
0

I found the simple solution in the manual

I just used my middle mouse button (see the manual for other options) to select my insertion point, and then I typed in what i wanted (or pasted it) and it worked.

Vijay
  • 1,130