Home Download Buy Blog Forum Support

Multiple Selection/Multiple Line Copy/Paste Replace

Multiple Selection/Multiple Line Copy/Paste Replace

Postby anshou on Fri Oct 19, 2012 5:11 pm

I have been using Sublime Text 2 for some quick multi-line text editing to clean up some CSV files. I have two files that are formatted similarly: two columns delimited by a common string. I have selected all the text in the first columns in both files. Both files have an equal number of lines.

What I am attempting to do is copy all the selected text from the second file and paste it into the first file, replacing text line by line.

Here is an illustrative example:

File 1:

abcd,xyz
bcde,yzx
cdef,zxy

File 2:

hijk,mno
ijkl,nom
jklm,omn

In file 1, I have selected the emphasized text:

abcd,xyz
bcde,yzx
cdef,zxy

In file 2, I have selected the emphasize text:

hijk,mno
ijkl,nom
jklm,omn

I could like to copy the text from file 2 and paste to file 1, and have file 1 result in the following text:

hijk,xyz
ijkl,yzx
jklm,zxy

Currently, when I copy and paste, the result is that the entirety of the copied text from file 2 is pasted to replace each line in file 1, resulting in the following:

hijk
ijkl
jklm,xyz
hijk
ijkl
jklm,yzx
hijk
ijkl
jklm,zxy

This is not what I desire. For sake of completeness, I should note that while there is an equal number of lines, the length of the text on each individual line does not necessarily match as in my example. Line 1 being copied may be 'foobar' while line 1 being replaced may be 'foobarbaz' or even 'foo'.

Thoughts? Help? Thanks you in advance!
anshou
 
Posts: 2
Joined: Fri Oct 19, 2012 4:59 pm

Re: Multiple Selection/Multiple Line Copy/Paste Replace

Postby adzenith on Fri Oct 19, 2012 5:19 pm

Are you sure it's the same number of lines? You have to have an identical number of selections for Sublime Text to do a 1:1 mapping; otherwise it'll paste all of the copied lines as you describe below.
Another thing to watch out for is newlines—if you select any newlines, then the paste will be annoying like that.
adzenith
 
Posts: 1216
Joined: Mon Oct 19, 2009 9:12 pm

Re: Multiple Selection/Multiple Line Copy/Paste Replace

Postby anshou on Fri Oct 19, 2012 5:27 pm

I just tried it again after reading your response and it worked. No idea what I had been doing differently before. Perhaps I had an extra selection somewhere I did not notice. Thanks very much for the reply!
anshou
 
Posts: 2
Joined: Fri Oct 19, 2012 4:59 pm


Return to General Discussion

Who is online

Users browsing this forum: Exabot [Bot] and 14 guests