Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
FANDOM
Explore
Current Wiki
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
GNU/Linux clipboard copy/paste with xclip
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
GNU/Linux clipboard copy/paste with xclip
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{review}} {{TipImported |id=964 |previous=962 |next=965 |created=2005 |complexity=basic |author=Al Vega |version=6.0 |rating=14/9 |category1=Integration |category2= }} From http://people.debian.org/~kims/xclip/ :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: <pre> :map <F7> :w !xclip<CR><CR> :vmap <F7> "*y :map <S-F7> :r!xclip -o<CR> </pre> 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 <code>"*p</code> is ''slow'' with a lot of data. ==Comments== 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 <pre> set guioptions=aAimrLT </pre> ---- Why use another utility when you can just have something like: <pre> map <F7> gg"*yG<C-o><C-o> map <S-F7> "*p </pre> ---- But it doesn't work with Vim 6.3.82. <code>"*y</code> 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: <pre> vmap <F6> :!xclip -f -sel clip<CR> map <F7> :-1r !xclip -o -sel clip<CR> </pre> ---- 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: <pre> map <F7> mz:-1r !xclip -o -sel clip<CR>`z </pre> ---- The {{script|id=2098|text=fakeclip}} plugin provides comprehensive keyboard shortcuts for +clipboard disabled Vim. ----This guide really messy. Try [https://defuse.ca/blog/clipboard-over-ssh-with-vim.html this]: 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?
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Navigation
(
view source
)
Template:Review
(
view source
)
Template:Script
(
view source
)
Template:TipImported
(
view source
)
Follow on IG
TikTok
Join Fan Lab