Search code examples
vim

How to copy selected lines to clipboard in vim


How to copy selected lines to clipboard in vim. I know how to do it for all text files, but I want to do in for selected lines. Thanks!


Solution

  • SHIFTV puts you in select lines mode. Then "+y yanks the currently selected lines to the + register which is the clipboard. There are quite a few different registers, for different purposes. See the section on selection and drop registers for details on the differences between * and + registers on Windows and Linux. Note that there is only a distinction between "* and "+ for X11 systems. Under MS-Windows, use of "* and "+ is actually synonymous and refers to the gui-clipboard. So, on windows * (sharp) register can be used as well: "*y