Can vim use the system clipboard(s) by default?

Vim

Vim Problem Overview


I am running into several problems because vim's tabs are, for the lack of a better term, god awful. I want to start using multiple Gnome tabs instead, each with a different instance of vim. Everything should work fine, however, only the system buffer + can be used to share text. This makes all the commands two key strokes longer:

y y becomes " + y y

y w becomes " + y w

d ' k becomes " + d ' k

This is especially so when one considers that a simply yank/paste operation like so

y y p

becomes

" + y y " + p

Is there anyway to instruct vim to always use the system clipboard(s)?

EDIT see Here for more information on using multiple instances of vim across Gnome Terminal Tabs

Vim Solutions


Solution 1 - Vim

I found a solution to my problem here. If you add the following to your .vimrc file

set clipboard=unnamedplus

Everything you yank in vim will go to the unnamed register, and vice versa.

Solution 2 - Vim

By the way, if you just want to use the terminal's native copy/paste handling, suggest setting

:se mouse-=a

and just doubleclick/rightclick as you're used to in your terminal.

That said, I love vim split windows and the fact that you can use the mouse to drag window dividers/position the cursor (heresy!). That requires mouse+=a... (and will work over ssh/screen sessions as well!).

I'm used to doing things like this instead:

:%retab|%>|%y+|u

and have commands like that on recall. Note that the "+ register is coded in the command line. To copy the last visual selection to the clipboard,

:*y+

or

:'<,`>y+ 

Solution 3 - Vim

Possible workaround:

"Ctrl-c to copy in + buffer from visual mode
vmap <C-c> "+y

"Ctrl-p to paste from the + register in cmd mode
map <C-v> "+p

"Ctrl-p to paste from the + register while editing
imap <C-v> <esc><C-v>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpukView Question on Stackoverflow
Solution 1 - VimpukView Answer on Stackoverflow
Solution 2 - VimseheView Answer on Stackoverflow
Solution 3 - VimVincenzo PiiView Answer on Stackoverflow