Hacker News new | ask | show | jobs
by _odey 768 days ago
"Nvim 0.10 can now use the OSC 52 escape sequence to write to (or read from) the system clipboard."

This is a big deal! (it shouldn't be, but it is)

My main complaints about vim/emacs in the past was at the sheer complexity of getting something that should not even be a concern (clipboard integration) working properly, when other text/code editors did not have this problem at all.

Searching online, it seems like tmux has some nice documentation related to OSC 52 usage:

https://github.com/tmux/tmux/wiki/Clipboard

I will be playing around with this for a bit to understand it more. But honestly, this is the sort of thing that should "Just Work TM".

"VTE terminals (GNOME terminal, XFCE terminal, Terminator) do not support the OSC 52 escape sequence."

https://gitlab.gnome.org/GNOME/vte/-/issues/2495

That's a shame, but I'm not against using a different terminal emulator. Up until now I did not really have a good reason to.

1 comments

> My main complaints about vim/emacs in the past was at the sheer complexity of getting something that should not even be a concern (clipboard integration) working properly

What problems have you encountered? I have the following shortcuts in my .vimrc:

    vnoremap <Leader>y "*y
    noremap <Leader>p "*p
    vnoremap <Leader>c "+y
    noremap <Leader>v "+p
Space + y/p is the copying/pasting from/to the "primary selection" (the mouse middle click). Space + c/v is copying/pasting from/to the regular ctrl+c/ctrl+v clipboard.

This... just works for me?

My solution is to have this snippet in my vimrc. Don't ask me why this works. It's been years, and I had no issues with it.

    " System-agnostic setting making the unnamed clipboard register act like
    " clipboard in any other editor. Copy with y commands, and paste with p or P.
    if has('unnamedplus')
        set clipboard=unnamedplus,unnamed
    else
        set clipboard+=unnamed
    endif
Beside this, there is also the issue of setting paste when pasting in insert mode.