2

What line should I add in my vimrc to easily copy/paste between terminals or between different files/tabs?

I now have:

" Better copy & paste
set pastetoggle=<F2>
set clipboard=unnamed

I use my vim as Python IDE, never had problems so far, but it doesn't seem to handle copy/paste between 2 different files/tabs.

What line should I add? What do you use to copy/paste between different terminals or tabs?

Jonah Bishop
  • 12,279
  • 6
  • 49
  • 74
An0n
  • 705
  • 6
  • 19
  • 2
    The easiest way to handle this is usually to use vims built-in system of tabs/buffers to copy paste within one instance of vim. If you definitely need to use the clipboard you will need a version of vim that has it enabled, like gvim. You can very easily copy between two different files by just opening both files in vim. – blues Feb 25 '19 at 18:05
  • 1
    Possible duplicate of [How to copy to clipboard in Vim?](https://stackoverflow.com/questions/3961859/how-to-copy-to-clipboard-in-vim) – blues Feb 25 '19 at 18:08

1 Answers1

2

It is personal preference, but i use the standard:

"+y
"+p

I like that this works by default and for me, it has became a 'finger macro' that i can type easily and quickly. You could assign these to something else if you like but i find this works fine as is.

A vimtip was linked in the below wiki which remaps the sequence to the following:

vmap <C-Space> "ay
nmap <C-Space> "aP
imap <C-Space> <C-o>"ap
nmap <C-c> "ayiw

vimwiki explanation: https://vim.fandom.com/wiki/Copy,_cut_and_paste

unlike most text editors, Vim distinguishes between its own registers and the system clipboard. By default, Vim copies to, cuts to, and pastes from its own default register, called the unnamed register ("", also called quotequote) instead of the system clipboard.

Assuming Vim was compiled with clipboard access, it is possible to access the "+ or "* registers, which can modify the system clipboard. In this case, one can copy with e.g. "+y in visual mode, or "+y{motion} in normal mode, and paste with e.g. "+p.

If your installation of Vim was not compiled with clipboard support, you must either install a package that has clipboard support, or use an external command such as xclip as an intermediary. See Accessing the system clipboard for detailed information.

axwr
  • 2,118
  • 1
  • 16
  • 29