@swpd's answer improved
I use ,
as a leader key and ,a
shortcut does the trick
Add this line if you prefer ,a
shortcut
map <Leader>a :%y+<CR>
I use Ctrl y
shortcut to copy
vmap <C-y> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR>
And ,v
to paste
nmap <Leader>v :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p
Before using this you have to install xclip
$ sudo apt-get install xclip
Edit: When you use :%y+
, it can be only pasted to Vim vim Ctrl+Insert
shortcut.
And
map <C-a> :%y+<Esc>
is not conflicting any settings in my Vimrc.