You are not logged in.

#1 2006-11-25 14:40:31

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

massive copy to system clipboard with vim?

Say I'm editing a program with vim through a terminal (say xterm). Does anyone know how to copy the contents, via left click highlighting, onto the system clipboard (x11) when the content that needs to be copied is physically off the screen? I've tried to arrow up while highlighting but it doesn't work.

Offline

#2 2006-11-25 15:21:47

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: massive copy to system clipboard with vim?

I've never tried this (and I can't check because I'm in Windows at the moment).

http://vim.sourceforge.net/tips/tip.php?tip_id=71

Also, take a look at the 'x11-selection' section of the Vim docs (http://ianua.initd.org/vimit/vim63/html/gui_x11.html)

Offline

#3 2006-11-25 15:40:57

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: massive copy to system clipboard with vim?

arooaroo wrote:

I've never tried this (and I can't check because I'm in Windows at the moment).

http://vim.sourceforge.net/tips/tip.php?tip_id=71

Also, take a look at the 'x11-selection' section of the Vim docs (http://ianua.initd.org/vimit/vim63/html/gui_x11.html)

Thanks arooaroo but I'm still not seeing it.
What I'm looking for is the ability to highlight above or below what is on the physical screen. Like say you highlight this page by left clicking and drag it up above the actuall text area say into the forward and back buttons on your web browser the selection of your text moves up on the page until you move it down again then the selection stops. Thats what I'm looking for.

Offline

#4 2006-11-25 15:52:07

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: massive copy to system clipboard with vim?

But you're in an xterm. You can't do that. You have to use vim's visual mode to select the text with cursor keys, then send to the clipboard.

Offline

#5 2006-11-30 23:02:24

toxic
Member
Registered: 2006-06-05
Posts: 117

Re: massive copy to system clipboard with vim?

arooaroo, vim keeps it's own buffer. I've never managed to copy something from the vim buffer to X11's buffer. And that's probably because I didn't read the manual properly tongue

Offline

#6 2006-11-30 23:22:49

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: massive copy to system clipboard with vim?

toxic, from what I understand from t-dawg's questions is that he wants to emulate what you can do in gvim, but with vim instead.

In gvim, I can click the mouse button; hold; drag downwards and then gvim will start scrolling downwards, whilst highlighting the passing lines. This is how you highlight large amounts of text (greater than what can fit in a single screen at a time) with a mouse.

However, terminals are slightly dumber. Whilst you can highlight areas of text, that's a console function and not something that vim itself is monitoring. Therefore, you can't achieve the same effect with the mouse in vim as you can in gvim.

Of course, vim is perfectly capable of selecting more text than can fit in a single screen. It has a visual mode. Press v and then move down with your cursor keys, et volia - highlighted text.

Now when it comes to shifting this to X11's clipboard, I've never tried (hence the link I gave for possible help). I'm sure it can be done.

Offline

#7 2006-11-30 23:52:04

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: massive copy to system clipboard with vim?

Under arch, vim is compiled with minimal options - installing gvim makes the vim binary "more capable" - adding python, perl, ruby support as well as enabling +xterm_clipboard.
With +xterm_clipboard enabled, the * register maps to the X11 clipboard. (:h quotestar).  Therefore, yanking to this register uses the same syntax as any other register:

"*y

To yank an entire file into X11s clipboard:

gg"*yG

Offline

#8 2006-11-30 23:56:36

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: massive copy to system clipboard with vim?

arooaroo wrote:

However, terminals are slightly dumber. Whilst you can highlight areas of text, that's a console function and not something that vim itself is monitoring. Therefore, you can't achieve the same effect with the mouse in vim as you can in gvim.

Not always.  In *good* terminals (urxvt, xterm, maybe others), you can use terminal vim's "ttymouse" mode.
I use

set ttymouse=xterm
set mouse=a

Check the help for full info about these options.  As far as I know ttymouse=xterm2 is only supported in xterm.  The difference is in dragging.  ttymouse=xterm does not report the mouse position when dragging, only on mouse presses, so you don't get a highlight until a mouse-up.

Offline

#9 2006-12-01 00:25:06

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: massive copy to system clipboard with vim?

So to answer the original question:

T-Dawg wrote:

Say I'm editing a program with vim through a terminal (say xterm). Does anyone know how to copy the contents, via left click highlighting, onto the system clipboard (x11) when the content that needs to be copied is physically off the screen? I've tried to arrow up while highlighting but it doesn't work.

First, install gvim, but keep using vim.

With the mouse:

set ttymouse=xterm2
set mouse=a
" use the same clicky way you would in gvim

Without the mouse:

gg"*yG

Offline

#10 2006-12-01 00:52:32

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: massive copy to system clipboard with vim?

"*y

Excellent! That worked with -X switch in vim. Thanks alot guys.

Offline

Board footer

Powered by FluxBB