1. 程式人生 > >vim呼叫系統剪下板複製貼上

vim呼叫系統剪下板複製貼上

文章參考:http://vim.wikia.com/wiki/In_line_copy_and_paste_to_system_clipboard。

將以下內容新增到~/下的.vimrc

" On OSX
vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
nmap <C-v> :call setreg("\"",system("pbpaste"))<CR>p

" On ubuntu (running Vim in gnome-terminal)
" The reason for the double-command on <C-c> is due to some weirdness with the X clipboard system.
vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR>
nmap <C-v> :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p