Sublime Forum

Copy Edit - fix multiple selection copy/paste

#1

Inspired by xavi-'s excellent Select-Until, which finally solved one of the most annoying problems I had with Sublime Text, I decided to buckle down and fix copy and paste once and for all, laying to rest the other of my two most annoying problems.

This plugin is for everyone who’s ever copied two chunks of code with newlines in them, and yelled at the computer when paste didn’t work right: now it does.

It also lets you do complicated things like paste multiple selections into fewer selections, and vice versa. I don’t know if that’s actually useful, but maybe it’s more useful than the built-in behaviour.

It should be transparent and seamless and just work on all platforms. I’ve been running it all day and loving it.

github.com/adzenith/CopyEdit

Feedback is welcome, as always!

0 Likes

#2

Neat idea !

I just sent a pull request which fixes a minor issue with the .sublime-keymap files.

Also, when Copy Edit is active I can’t do any copy and pasting.

I’m running ST2 on OS X 10.7.

0 Likes

#3

I guess I could try to get it to work in ST2… lemme see.

0 Likes

#4

Fixed for ST2. Should work everywhere now.

0 Likes

#5

Thanks ! It works now.

0 Likes

#6

One more ST2 issue. The shortcut key for cutting isn’t working for some reason.

0 Likes

#7

ST2, you’re killing me! Fixed cut as well.
Also, if you’ve never used Sublime’s console (ctrl+`) it is full of useful information about problems.

0 Likes

#8

Awesome, thank you.

0 Likes

#9

Looks cool. Thanks! I can’t tell you how many time ST has pissed me off in regards to copy/paste.

0 Likes

#10

Turns out the clipboard solution I was using doesn’t work for unicode characters… I may have just lost some text. :confused: I’ll try to figure something out soon.

0 Likes

#11

Turns out the clipboard solution works just fine… but Sublime Text sets the default encoding to ascii (!!!) so that the subprocess communication breaks when communicating with the clipboard helpers. Anyone know how to fix that?

0 Likes

#12

This is awful. Seriously, does anyone know why pyperclip would work just fine in the terminal and literally everywhere but in Sublime Text? ST, why do you have to mess with python so much… it works just fine normally…

0 Likes

#13

Pester Jon to compile it to use unicode :smile:. Not sure if there is some other way. I plan on playing with your plugin this week. But while I say to pester Jon half jokingly…I am also half serious.

0 Likes

#14

Well as far as I can tell, everything works just fine as long as you don’t copy unicode, and the clipboard handler I’m using works just fine with unicode as long as you’re not using Sublime Text. Just in case you want to take a look :smile:

0 Likes

#15

Perhaps use decode() on strings ?
effbot.org/zone/unicode-objects.htm

0 Likes

#16

Well, here’s what happens, as far as I can tell. If I call string.encode(‘utf-8’) or whatever, then if I paste into a different application it comes out garbled - I guess the system clipboard isn’t utf-8? So somehow I need to be detecting what the system clipboard’s encoding is, or convince the clipboard to be utf-8, or I don’t know what.

But! If I use the same clipboard module from anywhere that’s not Sublime, I don’t need to call string.encode at all—it just works (except in Sublime Text, where it flips out when I paste - “can’t decode to ascii” by default, or garbles it if I try to decode as utf-8).

A lot of Googling and messing around with the code and I have gotten no further.

0 Likes

#17

I did not reviewed *completely *the code of this package, but, there is two api functions to read and write to clipboard, not sure if there is a good reason to do it in python. If there is a good reason just ignore my post, if not why don’t use the sublime API calls?
Thanks for this plugin, is useful

0 Likes

#18

…Well I’ll be.

0 Likes

#19

[quote=“adzenith”]

…Well I’ll be.[/quote]

That’s funny, for some reason I didn’t even think about the API copy/paste…and I have used it in some of my plugins…if it were a snake…

0 Likes

#20

Pushed it real good.
Looks to be 100% now. I can copy and paste Unicode to my heart’s content.
Tito: you rock.

0 Likes