Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2 Appending 1 column to another

Ok, so I have 2 files with a lot of data in columns that I need join. I'm finding it hard to put into words so let me try and give an example.

File 1 contains:

Server1; 15min load 0.20 at 16 CPUs;
Server2; 15min load 0.46 at 4 CPUs;
Server3; 15min load 0.10 at 16 CPUs;
...

File 2 contains:

72.4% (12.01)
73.9% (12.26)
72.1% (11.97)
...

What I need is:

Server1; 15min load 0.20 at 16 CPUs; 72.4% (12.01)
Server2; 15min load 0.46 at 4 CPUs; 73.9% (12.26)
Server3; 15min load 0.10 at 16 CPUs; 72.1% (11.97)
...

The dots represent thousands more lines hence the need for automation. I've tried everything that might work:

  1. Ctrl + a in file 2 then Ctrl + a, Ctrl + Shift + L in file 1 before pasting
  2. Ctrl + a, Ctrl + Shift + L in file 2 then Ctrl + a, Ctrl + Shift + L in file 1 before pasting

I've somehow done this before but am now struggling to replicate.

I'm aware this can be done in shell script but I'm really curious as to how Sublime text manages it.

Thanks in advance!

like image 827
Ollie Jones Avatar asked Apr 26 '13 08:04

Ollie Jones


People also ask

How edit multiple lines sublime?

Multi-line editing. Most commonly I use cmd+d to select the next instance of selected text. In the animation below I select the first instance (with alt+shift+left ), then press cmd+d to select the next instance. If you want to skip an instance you can press cmd+k, cmd+d .


2 Answers

Go to the file2, press:

Ctrl+A, Ctrl+c (select all, then copy)

...

Then go the the file1 and press in sequence:

Ctrl+a, Ctrl+Shift+L, , Space, Ctrl+v (select all, split into lines, move cursor to the end of each line, insert a space, paste the contents.

like image 80
Hugo Corrá Avatar answered Sep 28 '22 04:09

Hugo Corrá


The answer outlined by @HugoCorrá does still work in Sublime 3 on Windows 8. But you MUST make sure that the number of lines selected, matches the number of lines to paste or it does not work (it will paste a copy of the whole clipboard in each selection).

Alternatively use the text pastry plugin for Sublime, a really nice tool for multi-line pasting. The difference being, you select the text to paste with a standard CTRL + A Ctrl + C. Then select all the paste points in the second document (as @HugoCorrá specified), but don't do a Ctrl + V. Instead use text pastry Ctrl + Alt + N. Then in the command prompt use \p to paste from the clipboard. An example is given here.

like image 28
Damo Avatar answered Sep 28 '22 03:09

Damo