|
|
Subscribe / Log in / New account

New features in Neovim 0.5

New features in Neovim 0.5

Posted Aug 5, 2021 15:05 UTC (Thu) by mathstuf (subscriber, #69389)
In reply to: New features in Neovim 0.5 by flussence
Parent article: New features in Neovim 0.5

Hmm. When selecting text in vim for middle-click paste, I get all kinds of padding spaces and such mixed in with the copy that I have to fix on the other side (which, inevitably, is missing useful editing tools and is a manual process to fix). I've started getting into the habit of using visual selection and then `:w!xsel -i -p` to send it to the clipboard. Are you using `:set mouse` (I have it off in tmux as well as vim/neovim)?


to post comments

New features in Neovim 0.5

Posted Aug 7, 2021 12:24 UTC (Sat) by mgedmin (subscriber, #34497) [Link]

There are multiple ways of using copy/paste with vim in the console. Either you let vim talk to your display server (:set mouse=a, plus vim needs to be built with X11 support and the clipboard feature), in which case MiddleMouse will paste from the selection register. This becomes more complicated if you use Vim remotely (over ssh, which would need ssh's X11 forwarding enabled), especially if you also use screen/tmux (when you reattach an older session, $DISPLAY value may be wrong).

The other way is you let the terminal handle the pasting (if you use :set mouse=a, for most terminal emulators you can override it by holding down shift when middle-clicking). Recent versions of Vim support xterm's bracketed paste, so the paste should gets detected and work fine. Older versions of Vim see a bunch of keypresses, so you need to go into insert mode before pasting, and disable things like autoindent -- for which there's a handy :set pastetoggle=..., so you can hit a key, paste, then hit the key again.

For copying, there's no equivalent to xterm's bracketed paste, so you either need to use the clipboard feature and yank into the "* register, or you need to hold down shift while selecting text (which is hard if you use vertical splits or if the lines are longer than the width of the window, or if you want to preserve tabs).


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds