Reputation: 455
I'd like to be able to copy and paste using the system clipboard without having to toggle paste mode every time. Is there a way to do that?
If it matters at all, I'm using vim from the terminal on a Mac.
Upvotes: 0
Views: 200
Reputation: 30398
If you mean you want to be able to safely paste or copy raw text in the terminal without having to type :set paste
beforehand and :set nopaste
afterwards, you have a few options.
Set the 'pastetoggle'
option. See :help 'pastetoggle'
, which gives this usage example:
:map <F10> :set paste<CR>
:map <F11> :set nopaste<CR>
:imap <F10> <C-O>:set paste<CR>
:imap <F11> <nop>
:set pastetoggle=<F11>
Create mappings for :set paste
and :set nopaste
, like in the above code.
yo
and yO
that :set paste
, do o
or O
, and then automatically :set nopaste
when you exit Insert mode.If you mean you want commands like y
and p
to copy to and paste from the system clipboard by default, then just see the existing question How to make Vim paste from (and copy to) system’s clipboard?
Upvotes: 3