martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.2k stars 258 forks source link

Send all lines with /regex/ to system clipboard #973

Closed honestSalami closed 2 years ago

honestSalami commented 2 years ago

I'm trying to send all lines that contain a pattern to the system clipboard. This is useful if (for example) I want all the function definitions in a python file.

My attempt thus far has been ,x/.+\n/ g/regex/ > xsel -ip, but that only writes the LAST line containing the pattern to the clipboard (probably because each new dot overwrites the previously written dot). How can I send the ENTIRE selection to the clipboard?

honestSalami commented 2 years ago

I thought about appending each dot to a register, and then sending that register to xsel, but I don't know how to 1) save dots to a register, nor how to 2) execute a command after ALL matches have been made.

honestSalami commented 2 years ago

I found a way to send each line to the system clipboard, but without linebreaks: :,x > xsel -ab

honestSalami commented 2 years ago

here's how you can send the entire file to the clipboard: ,x/(.|\n)+/ > xsel -ib. and you can do the same appending trick above for any selection: ,x/regex/ > xsel -ab. Since this is what I set out to do, I'll consider this issue closed.