created 2005 · complexity basic · author Al Vega · version 6.0
- xclip is a command line utility that is designed to run on any system with an X11 implementation. It provides an interface to X selections ("the clipboard") from the command line. It can read data from standard in or a file and place it in an X selection for pasting into other X applications. xclip can also print an X selection to standard out, which can then be redirected to a file or another program.
I have had a lot of pain with the clipboard until xclip appeared in scene. I mix it with Vim in the following way:
:map <F7> :w !xclip<CR><CR> :vmap <F7> "*y :map <S-F7> :r!xclip -o<CR>
Press F7 to copy all current buffer to clipboard, or a selection, or press shift-F7 to paste all clipboard contents.
I prefer doing this way because
"*p is slow with a lot of data.
Comments[edit | edit source]
I set the 'a' and 'A' options for guioptions, which copies gvim text to the clipboard. I'm using FC4/KDE.
The 'a' and 'A' options enables copying selected text to system clipboard
Why use another utility when you can just have something like:
map <F7> gg"*yG<C-o><C-o> map <S-F7> "*p
But it doesn't work with Vim 6.3.82.
"*y doesn't copy the selection into my XA_PRIMARY, XA_CLIPBOARD or secondary clipboard under RHEL4.0.2 with gnome.
- The clipboard feature must be enabled at compile time. Check with vim --version | grep +clipboard. On Fedora the feature is enbaled only in vimx from the vim-X11 package.
This works for me - F6 to copy and F7 to paste:
vmap <F6> :!xclip -f -sel clip<CR> map <F7> :-1r !xclip -o -sel clip<CR>
I like the above mapping for F6 and F7, but my position changes on the page when pasting with F7. Use this F7 map to preserve your location on the text file:
map <F7> mz:-1r !xclip -o -sel clip<CR>`z
The fakeclip plugin provides comprehensive keyboard shortcuts for +clipboard disabled Vim.
This guide really messy.
However, I still can't copy the remote server's data and paste locally.
I ran this: In client # ssh -X root@IP > vim file > yanked > in this local machine paste, but only pasted the local machine data, not the server's data?
Maybe the server needs a restart?