Vim Tips Wiki
m (Protected "GNU/Linux clipboard copy/paste with xclip": discourage nonsense ([edit=sysop] (expires 01:17, April 7, 2011 (UTC)) [move=sysop] (expires 01:17, April 7, 2011 (UTC))))
No edit summary
Tags: Visual edit apiedit
 
(8 intermediate revisions by 3 users not shown)
Line 7: Line 7:
 
|complexity=basic
 
|complexity=basic
 
|author=Al Vega
 
|author=Al Vega
|version=5.7
+
|version=6.0
 
|rating=14/9
 
|rating=14/9
 
|category1=Integration
 
|category1=Integration
Line 24: Line 24:
 
Press F7 to copy all current buffer to clipboard, or a selection, or press shift-F7 to paste all clipboard contents.
 
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 <tt>"*p</tt> is ''slow'' with a lot of data.
+
I prefer doing this way because <code>"*p</code> is ''slow'' with a lot of data.
   
 
==Comments==
 
==Comments==
Line 44: Line 44:
 
But it doesn't work with Vim 6.3.82.
 
But it doesn't work with Vim 6.3.82.
   
<tt>"*y</tt> doesn't copy the selection into my XA_PRIMARY, XA_CLIPBOARD or secondary clipboard under RHEL4.0.2 with gnome.
+
<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.
 
: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.
Line 62: Line 62:
   
 
----
 
----
[http://www.vim.org/scripts/script.php?script_id=2098 fakeclip] plugin provides comprehensive keyboard shortcuts for +clipboard disabled Vim.
+
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?

Latest revision as of 02:14, 27 September 2015

Tip 964 Printable Monobook Previous Next

created 2005 · complexity basic · author Al Vega · version 6.0


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:

: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[]

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

set guioptions=aAimrLT

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.

Try 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?