Home Download Buy Blog Forum Support

Paste As Block

Paste As Block

Postby bbehrens on Wed Nov 14, 2012 4:58 pm

I really like Sublime Text 2 but there is one feature that I wish it had. I use Textpad which allows you to paste a block of text with a document. Using Text pad, you find the point of insertion and right click, choose insert, paste as block.

Example:

abcd123
efghi456
jklmn789

It would be nice if I could right click between the d and the 1 and paste a block of text so it would look like this:

abcd00a123
efgh00a456
ijkl00a789
bbehrens
 
Posts: 1
Joined: Wed Nov 14, 2012 4:51 pm

Re: Paste As Block

Postby Clams on Thu Nov 15, 2012 6:49 am

I made a very simple plugin that does exactly that : it's in package control under the name "Paste as Column" (default shortcut is ctrl+alt+v).
Repo is https://bitbucket.org/Clams/sublimepastecolumn in case you need to install it manually.

Note that sublimeText already handle this kind of stuff but not in the exact way you are describing: if you do copy a block of text of n line and then put exactly n cursor the default paste function will insert each line where are each cursor. The behavior is slightly different, and in the end I use both :P
Clams
 
Posts: 47
Joined: Fri Dec 30, 2011 7:44 am

Re: Paste As Block

Postby highend on Thu Nov 15, 2012 8:54 am

I'm unsure how to use your plugin, Clams.

Three lines:
abcd123
efghi456
jklmn789


I want to paste 00a after the first d in the first line for all three lines (I take the example of the first post).
After placing the cursor and hitting ctrl+alt+v only the first line is modified. Line 2 and 3 are untouched.

Your plugin get's executed:
key evt: control+alt+v
command: paste_column
Modifying line 0 at col 4 ##abcd123##--00a-- with start=0 end=7 prev=-1

Did I do anything wrong?
highend
 
Posts: 94
Joined: Fri Jan 20, 2012 2:47 pm

Re: Paste As Block

Postby bizoo on Thu Nov 15, 2012 10:03 am

Until ST2 gain the possibility to read your mind, you have to tell it how many lines you want to paste.
So for your example, your clipboard must contains 3 lines:
Code: Select all
00a
00a
00a

Or as Clams explained, you must create 3 cursors and use the default paste with 1 or 3 lines in your clipboard (you know how multi-selection work in ST2, right ?)
bizoo
 
Posts: 886
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Paste As Block

Postby Clams on Thu Nov 15, 2012 10:04 am

The plugin recopy a block of text (multiple line) and insert it wherever you want.
If your block is only one line, then it just behave like a simple paste.

Maybe a better exemple would be:

abcd0123
efgh1456
jklm2789

imagine that you copy somewhere the following block

00a0
00a1
00a2

if you place the cursor after the d and hit ctrl+alt+v you would get
abcd00a0123
efgh00a1456
jklm00a2789

And the other where I think it start to be really useful is when you try to do that let's say 4 character after the 0123: you insert space in the first line to put your cursor there, and then it ctrl+alt+v and you get

abcd123 0a01
efgh456 00a1
jklm789 00a2

with the space at the end of other line inserted, something that you cannot do easily with ST2 since you cant put cursor after the end of the line.


If you simply want to repeat on multiple line the same text then you can simply use the multiselection from ST2, then paste and it works fine without any plugin.

Edit: bah, I'm too slow, Bizoo explained itperfectly :P
Clams
 
Posts: 47
Joined: Fri Dec 30, 2011 7:44 am

Re: Paste As Block

Postby highend on Thu Nov 15, 2012 10:32 am

Until ST2 gain the possibility to read your mind, you have to tell it how many lines you want to paste.


That's what I was waiting for^^ :)

Thanks for the explanations, got it now...
highend
 
Posts: 94
Joined: Fri Jan 20, 2012 2:47 pm

Re: Paste As Block

Postby MichaelTunnell on Mon May 20, 2013 9:25 pm

Clams wrote:I made a very simple plugin that does exactly that : it's in package control under the name "Paste as Column" (default shortcut is ctrl+alt+v).
Repo is https://bitbucket.org/Clams/sublimepastecolumn in case you need to install it manually.

Note that sublimeText already handle this kind of stuff but not in the exact way you are describing: if you do copy a block of text of n line and then put exactly n cursor the default paste function will insert each line where are each cursor. The behavior is slightly different, and in the end I use both :P

THANK YOU VERY MUCH! This package worked perfectly for what I was needing to do...it let me paste over 300 rows with ease...huge time saver. Thanks again.
MichaelTunnell
 
Posts: 2
Joined: Mon May 20, 2013 9:19 pm

Re: Paste As Block

Postby tri.taurus on Wed Mar 26, 2014 9:49 pm

Simple way to do this.

1. Select the text to paste as a block (On Mac: Option + Drag mouse)
2. Select the part where you want to paste as a block (if beginning of line, just drag a vertical line)
3. Paste

A little long, but works well
tri.taurus
 
Posts: 1
Joined: Wed Mar 26, 2014 9:47 pm

Re: Paste As Block

Postby dhjdhj on Thu Apr 03, 2014 1:56 am

I am in heaven!!! As a forever SlickEdit user now moving to Sublime, the lack of block pasting was the only problem for me ---

Thank you.
dhjdhj
 
Posts: 2
Joined: Wed Mar 26, 2014 1:13 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests