← Back to context

Comment by em-bee

1 day ago

but it's non-trivial to copy that selection to the outside of vim to another app.

i can select a column in tmux too, using tmux commands, and then it's the same problem. i can't use that selection outside of tmux.

i simply want the GUI to be aware that there are multiple columns in the terminal and let me select text within one using the mouse and then copy that to a different window/app.

> it's non-trivial to copy that selection to the outside of vim to another app

A correctly compiled Vim will make the two X clipboards (“selections”) available as registers * (“primary”, i.e. the current selection, pasteable with the middle mouse button) and + (“secondary”, accessed with Ctrl-X/C/V) for both reading and writing. (I believe these are synonyms in graphical environments that don’t have two clipboards.) You can make one of them the default by adding

  set clipboard=unnamed

resp.

  set clipboard=unnamedplus

to your Vim configuration.

> i can select a column in tmux too, using tmux commands, and [...] i can't use that selection outside of tmux.

If you’re using Wayland on Linux, install wl-clipboard and put

  set-option -s copy-command wl-copy

in your tmux configuration, and mutatis mutandis for other (local) graphical environments. Watch out for cases where you’ve trained yourself to assume that the tmux selection and the desktop’s clipboard aren’t the same thing. (I don’t know how I’d synchronize things in the other direction, that seems non-trivial.)

  • thank you. getting this to work would be awesome.

    • Now that I’m looking at this again, I remember that the wl-copy (or xcopy or pbcopy) thing is a workaround for GNOME’s VTE terminal widget refusing to support the OSC 52 escape sequence for setting the clipboard. If your terminal emulator does speak that one, then you should be able to use the set-clipboard option[1] instead, which also has the advantage of working over a remote connection (because it’s in-band).

      [1] https://github.com/tmux/tmux/wiki/Clipboard#the-set-clipboar...