martanne / vis

A vi-like editor based on Plan 9's structural regular expressions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to copy to system clipboard from multiple selections?

roguh opened this issue · comments

https://github.com/roguh/vis-copypasta

This simply adds keybindings to C-v and C-c.

It also has a README.

I'm not sure how to copy multiple selections to the clipboard, or how that should behave, but it'd be an interesting feature. I was thinking of how we could copy multiple selections, then with C-v, paste them back as multiple selections somehow.

I just added my plugin the page here: https://github.com/martanne/vis/wiki/Plugins

But I still want to discuss how to handle multiple selections and "*y

I'm not sure what the expected behavior should be. To me it only makes sense to copy the primary selection.

If you really want to copy multiple selections you could use the window:selections_iterator() to loop through and concatenate (possibly with some character or string in between) before copying to the clipboard. But I still don't what it would mean to paste such a string back into vis.

On the other hand most system clipboards don't mangle binary data so you could write some sort of data serializer that would only work with vis. But that's something that would kind of be covered by the client-server goal.

Thank you! I opened this issue mostly to request adding the plugin to the plugins list, but I could do that myself.

Perhaps I could define a special vis copy-paste that uses a binary format to copy and paste multiple selections somehow. Maybe the selections could be concatenated in a dynamic way, depending on the user's needs: C-c '\0' <Enter> or C-c ' ' <Enter> might copy the selections with the given separator.

Then how could one cut and then immediately paste multiple selections and expect no changes afterwards, like with a normal Ctrl-x Ctrl-v sequence?

Pasting with a custom separator might also be interesting. One could paste an arbitrary text and immediately place a selector on every match of a given regex, for instance.

It sounds like you've got the idea. The main issue I still see is what should happen when you copy N selections to the clipboard but you have M selections active when you try to paste.

Nothing against this plugin, but why it should remain in this issue tracker?

Sorry I'm bad at closing issues that aren't directly related to problems in the code; you are right and this can be closed.