I wonder, how i can enable auto copy of selected text into '+'
register in Ubuntu (to share clipboard between apps)?
i have set guioptions+=a (in win32, this works perfectly )
Please do not offer hand-click solutions like vmap <C-Insert> "+y
> I wonder, how i can enable auto copy of selected text into '+' > register in Ubuntu (to share clipboard between apps)? > i have set guioptions+=a (in win32, this works perfectly )
> Please do not offer hand-click solutions like vmap <C-Insert> "+y
> -- > You received this message from the "vim_use" maillist. > Do not top-post! Type your reply below the text you are replying to. > For more information, visit http://www.vim.org/maillist.php
You can add unnamedplus to your 'clipboard' setting. See ":help 'cb'". For example I use: set clipboard=unnamedplus,unnamed,autoselect,exclude:cons|linux
> > I wonder, how i can enable auto copy of selected text into '+'
> > register in Ubuntu (to share clipboard between apps)?
> > i have set guioptions+=a (in win32, this works perfectly )
> > Please do not offer hand-click solutions like vmap <C-Insert> "+y
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visithttp://www.vim.org/maillist.php
> You can add unnamedplus to your 'clipboard' setting. See ":help 'cb'".
> For example I use:
> set clipboard=unnamedplus,unnamed,autoselect,exclude:cons|linux
On Friday, April 20, 2012 3:38:22 PM UTC-5, Sergey Vakulenko wrote: > Hi Marcin
> I tried, but this not works for me :(
> set clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
> test case: > 1) open gvim > 2)shift-v, move cursor and Esc (select lines in visual mode) > 3)go to firefox and click ctrl-v or ctrl-Insert
Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
On Apr 21, 6:50 am, Ben Fritz <fritzophre...@gmail.com> wrote:
> On Friday, April 20, 2012 3:38:22 PM UTC-5, Sergey Vakulenko wrote:
> > Hi Marcin
> > I tried, but this not works for me :(
> > set clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
> > test case:
> > 1) open gvim
> > 2)shift-v, move cursor and Esc (select lines in visual mode)
> > 3)go to firefox and click ctrl-v or ctrl-Insert
> Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
Well if you pasted it correctly you used a forward slash and not a
pipe.
> set clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
>Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow
>this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
Im not use mouse for copy paste. Also, i used this feature (copy on
select) on Win XP 4 years. I cant understand how i cant do the same in
Ubuntu.
Please, help me!
On Apr 21, 10:17 am, Christian Brabandt <cbli...@256bit.org> wrote:
> >Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow > >this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
> Im not use mouse for copy paste. Also, i used this feature (copy on > select) on Win XP 4 years. I cant understand how i cant do the same in > Ubuntu.
Either yank it using y and then Ctrl-V should simply work, or use a clipboard manager like parcellite, that syncs primary selection and the clipboard.
regards, Christian
-- Wer lange genug gelebt hat, hat alles gesehen und auch das Gegenteil von allem. -- Charles Maurice de Talleyrand
> >Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow > >this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
> Im not use mouse for copy paste. Also, i used this feature (copy on > select) on Win XP 4 years. I cant understand how i cant do the same in > Ubuntu.
Windows and X use different models for sharing a "clipboard" between applications. There is only only Windows clipboard but there are two X mechanisms: the selection and the clipboard. See :help x11-selection" for more on this. This can be confusing because when you "copy" in X, sometimes the copied text goes to the selection and sometimes it goes to the clipboard. Similarly, pasting may use either of these as the source. I'm sure it actually works very consistently, but I've never completely understood it.
Here's what I have in my ~/.vimrc:
if has("clipboard") set clipboard^=unnamed " The "exclude:" entry, which is present by " by default, must be last. Therefore, put " "unnamed" first. endif
With that, I am able to easily yank and paste between applications including vim and gvim. However, to paste into another X application such as Firefox, I must use the mouse middle button. Ctrl-V seems to use the other selection mechanism.
I tried changing "unnamed" to "unnamedplus" in the 'clipboard' setting and was able to use Ctrl-V for pasting in Firefox, but then was unable to use other mechanisms I was used to for copying and pasting, so I went back to "unnamed". I didn't investigate the behaviors thoroughly.
So I think you _can_ get copying and pasting to work well for you in Ubuntu, but it may not work the same as it did in Windows.
> On 2012-04-21, Sergey Vakulenko wrote: > > >Normally the selection register is pasted with a middle-click of the mouse, not with CTRL-V. 'clipboard' containing autoselect should allow > > >this. I have no idea whether it is possible to paste the selection with CTRL-V, but I don't think it is Vim which controls this.
> > Im not use mouse for copy paste. Also, i used this feature (copy on > > select) on Win XP 4 years. I cant understand how i cant do the same in > > Ubuntu.
> Windows and X use different models for sharing a "clipboard" between > applications. There is only only Windows clipboard but there are > two X mechanisms: the selection and the clipboard. See :help > x11-selection" for more on this. This can be confusing because when > you "copy" in X, sometimes the copied text goes to the selection and > sometimes it goes to the clipboard. Similarly, pasting may use > either of these as the source. I'm sure it actually works very > consistently, but I've never completely understood it.
> Here's what I have in my ~/.vimrc:
> if has("clipboard") > set clipboard^=unnamed " The "exclude:" entry, which is present by > " by default, must be last. Therefore, put > " "unnamed" first. > endif
> With that, I am able to easily yank and paste between applications > including vim and gvim. However, to paste into another X > application such as Firefox, I must use the mouse middle button. > Ctrl-V seems to use the other selection mechanism.
> I tried changing "unnamed" to "unnamedplus" in the 'clipboard' > setting and was able to use Ctrl-V for pasting in Firefox, but then > was unable to use other mechanisms I was used to for copying and > pasting, so I went back to "unnamed". I didn't investigate the > behaviors thoroughly.
If you add both of them (i.e. unnamed and unnamedplus) you will get what you want as I already pointed.
> On 15:26 Sat 21 Apr , Gary Johnson wrote: > > I tried changing "unnamed" to "unnamedplus" in the 'clipboard' > > setting and was able to use Ctrl-V for pasting in Firefox, but then > > was unable to use other mechanisms I was used to for copying and > > pasting, so I went back to "unnamed". I didn't investigate the > > behaviors thoroughly.
> If you add both of them (i.e. unnamed and unnamedplus) you will get what you > want as I already pointed.
I thought I also tried that when you first posted it. I thought I set both, yanked text from one vim instance with 'Y', then tried to put it into another vim instance with ":put". The ":put" text was not what I had just yanked but was from the other selection. I just tried it again after reading your latest reply and it seems to work. I was in a hurry and must have done something wrong the first time. I'll try it this week at work where it will get more of a workout.
Thanks for the tip and for insisting that it worked.
>> If you add both of them (i.e. unnamed and unnamedplus) you will get what you >> > want as I already pointed. > I thought I also tried that when you first posted it. I thought I > set both, yanked text from one vim instance with 'Y', then tried to > put it into another vim instance with ":put". The ":put" text was > not what I had just yanked but was from the other selection. I just > tried it again after reading your latest reply and it seems to work.
On Sun, Apr 22, 2012 at 02:11:47PM EDT, Gary Johnson wrote:
[..
> > If you add both of them (i.e. unnamed and unnamedplus) you will get > > what you want as I already pointed. > I thought I also tried that when you first posted it. > I thought I set both, yanked text from one vim instance with 'Y', then > tried [..]
Hello Gary,
That's a lot of ‘thinking’, don't you think..: no offense meant.. :-)
The ‘:registers’ command is the healthier methodology when monitoring cut's, copy's & paste's.
Whatever I do, mouse or nomouse, keyboard, joystick... -) .. the ‘:reg’ command lets me see exactly what is going on.. And if I'm not sure I get to :reg a second time, even a third time for free..
I used to have problems with the different copypaste scenarios, but now that I use ‘:reg’ on a regular basis, I always seem to end up with the copied stuff available somewhere or other.
> On Sun, Apr 22, 2012 at 02:11:47PM EDT, Gary Johnson wrote:
> [..
> > > If you add both of them (i.e. unnamed and unnamedplus) you will get > > > what you want as I already pointed.
> > I thought I also tried that when you first posted it.
> > I thought I set both, yanked text from one vim instance with 'Y', then > > tried [..]
> Hello Gary,
> That's a lot of ‘thinking’, don't you think..: no offense meant.. :-)
Hi Chris,
What are you, my English teacher? It's probably a defensive habit to give myself wiggle room. (Note the careful use of "probably" instead of "think".) You want to be my shrink, too? No offense taken. And none intended, honestly.
> The ‘:registers’ command is the healthier methodology when monitoring > cut's, copy's & paste's.
> Whatever I do, mouse or nomouse, keyboard, joystick... -) .. the ‘:reg’ > command lets me see exactly what is going on.. And if I'm not sure I get > to :reg a second time, even a third time for free..
> I used to have problems with the different copypaste scenarios, but now > that I use ‘:reg’ on a regular basis, I always seem to end up with the > copied stuff available somewhere or other.
Good idea. With that, I did some experimentation.
Case 1: clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
Copy text from a GNOME Terminal by dragging the mouse over it with the left button held down.
":registers" shows selected text in the * register. The contents of the + and " registers are unchanged from before the copy operation.
":put" pastes the contents of the + register, not what I wanted.
Case 2: clipboard=unnamed,unnamedplus,autoselect,exclude:cons\|linux
Copy text from a GNOME Terminal as before. ":registers" shows the same results as before, as expected.
":put" again pastes the contents of the + register.
Case 3: clipboard=unnamed,autoselect,exclude:cons\|linux
Copy text from a GNOME Terminal as before. ":registers" shows the same results as before, as expected.
":put" now pastes the contents of the * register.
So it appears that the only way to paste from the * register without explicitly naming it is to exclude "unnamedplus" from the 'clipboard', and that means that unnamed yanks from Vim go only to the * register and not the + register, which then means that Ctrl-V in Firefox won't paste that yanked text. That's really fine with me since I paste into X applications other than Vim with the middle mouse button, not Ctrl-V, but it's not what the OP wanted.
By naming registers, you can copy and paste any way you like in Vim, but I don't see a way to copy from Vim to another X application, or from another X application to Vim, without having to know about both the + and * registers. It would be nice if there was some way to avoid all that thinking.
On Mon, Apr 23, 2012 at 02:57:58AM EDT, Gary Johnson wrote: > On 2012-04-22, Chris Jones wrote: > > On Sun, Apr 22, 2012 at 02:11:47PM EDT, Gary Johnson wrote:
[..]
> What are you, my English teacher? It's probably a defensive habit to > give myself wiggle room. (Note the careful use of "probably" instead > of "think".) You want to be my shrink, too? No offense taken. And > none intended, honestly.
:-)
Forgive me... was in a ‘funny’ mood last night.. pixilated, perhaps..
> > The ‘:registers’ command is the healthier methodology when > > monitoring cut's, copy's & paste's. > Good idea. With that, I did some experimentation.
That was supposed to be the useful part.
The idea being that part of the problem is often in the mind, rather than actual facts. I'm not claiming that once I started using the :reg command to check the contents of Vim's registers on a regular basis all the problems just went away, but at least those problems that remained were genuine, not something I was making up.
> Case 1: > clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
> Copy text from a GNOME Terminal by dragging the mouse over it > with the left button held down.
> ":registers" shows selected text in the * register. The > contents of the + and " registers are unchanged from before the > copy operation.
> ":put" pastes the contents of the + register, not what I wanted.
> Case 2: > clipboard=unnamed,unnamedplus,autoselect,exclude:cons\|linux
> Copy text from a GNOME Terminal as before. ":registers" shows > the same results as before, as expected.
> ":put" again pastes the contents of the + register.
> Case 3: > clipboard=unnamed,autoselect,exclude:cons\|linux
> Copy text from a GNOME Terminal as before. ":registers" shows > the same results as before, as expected.
> ":put" now pastes the contents of the * register.
I'm still running Vim 7.2, so I have not had the opportunity to use unnamedplus as yet. My experience is limited to Case 3.
> So it appears that the only way to paste from the * register without > explicitly naming it is to exclude "unnamedplus" from the 'clipboard', > and that means that unnamed yanks from Vim go only to the * register > and not the + register, which then means that Ctrl-V in Firefox won't > paste that yanked text. That's really fine with me since I paste into > X applications other than Vim with the middle mouse button, not > Ctrl-V, but it's not what the OP wanted.
That's also what I am seeing (Case 3). But I run Vim under GNU/screen which I have customized to write to what Vim sees as the + register, X11's PRIMARY selection, IIRC.
From a more general perspective, the OP could use the ‘autocutsel’ program that keeps X11's clipboard & primary selection in sync'.
> By naming registers, you can copy and paste any way you like in Vim, > but I don't see a way to copy from Vim to another X application, or > from another X application to Vim, without having to know about both > the + and * registers. It would be nice if there was some way to > avoid all that thinking.
Another approach would be to figure out if there's any way GTK apps can be made to always use either the clipboard ("*) or X11's PRIMARY ("+) rather than a mix of both depending on what copy/paste mechanisme you are using.
> Case 1: > clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
> Copy text from a GNOME Terminal by dragging the mouse over it > with the left button held down.
> ":registers" shows selected text in the * register. The > contents of the + and " registers are unchanged from before the > copy operation.
> ":put" pastes the contents of the + register, not what I wanted.
> Case 2: > clipboard=unnamed,unnamedplus,autoselect,exclude:cons\|linux
> Copy text from a GNOME Terminal as before. ":registers" shows > the same results as before, as expected.
> ":put" again pastes the contents of the + register.
> Case 3: > clipboard=unnamed,autoselect,exclude:cons\|linux
> Copy text from a GNOME Terminal as before. ":registers" shows > the same results as before, as expected.
> ":put" now pastes the contents of the * register.
> So it appears that the only way to paste from the * register without > explicitly naming it is to exclude "unnamedplus" from the > 'clipboard', and that means that unnamed yanks from Vim go only to > the * register and not the + register, which then means that Ctrl-V > in Firefox won't paste that yanked text. That's really fine with me > since I paste into X applications other than Vim with the middle > mouse button, not Ctrl-V, but it's not what the OP wanted.
That should probably be documented. Here is a doc patch: diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -977,6 +977,11 @@ current line). This always works |linewise|, thus this command can be used to put a yanked block as new lines. + If no register is specified, it depends on the 'cb' + option, if 'cb' contains "unnamed", paste from + * register |quotestar|, if 'cb' also contains + "unnamedplus", use + register |quoteplus|, else paste + from the unnamed register |quote_quote|. The cursor is left on the first non-blank in the last new line. The register can also be '=' followed by an optional
regards, Christian -- Sind wohl solche Zahlzeichen m glich, die wenn ich das Blatt herumkehre und alsdann ausspreche z.E. so viel bedeuten als die H lfte der vorhergehenden.. -- Georg Christoph Lichtenberg
> > Case 1: > > clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
> > Copy text from a GNOME Terminal by dragging the mouse over it > > with the left button held down.
> > ":registers" shows selected text in the * register. The > > contents of the + and " registers are unchanged from before the > > copy operation.
> > ":put" pastes the contents of the + register, not what I wanted.
> > Case 2: > > clipboard=unnamed,unnamedplus,autoselect,exclude:cons\|linux
> > Copy text from a GNOME Terminal as before. ":registers" shows > > the same results as before, as expected.
> > ":put" again pastes the contents of the + register.
> > Case 3: > > clipboard=unnamed,autoselect,exclude:cons\|linux
> > Copy text from a GNOME Terminal as before. ":registers" shows > > the same results as before, as expected.
> > ":put" now pastes the contents of the * register.
> > So it appears that the only way to paste from the * register without > > explicitly naming it is to exclude "unnamedplus" from the > > 'clipboard', and that means that unnamed yanks from Vim go only to > > the * register and not the + register, which then means that Ctrl-V > > in Firefox won't paste that yanked text. That's really fine with me > > since I paste into X applications other than Vim with the middle > > mouse button, not Ctrl-V, but it's not what the OP wanted.
> That should probably be documented. Here is a doc patch: > diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt > --- a/runtime/doc/change.txt > +++ b/runtime/doc/change.txt > @@ -977,6 +977,11 @@ > current line). This always works |linewise|, thus > this command can be used to put a yanked block as new > lines. > + If no register is specified, it depends on the 'cb' > + option, if 'cb' contains "unnamed", paste from > + * register |quotestar|, if 'cb' also contains > + "unnamedplus", use + register |quoteplus|, else paste > + from the unnamed register |quote_quote|. > The cursor is left on the first non-blank in the last > new line. > The register can also be '=' followed by an optional
Hi Christian,
Because the presence of "unnamedplus" trumps "unnamed", I think it would be more clear if the options were described in this order.
if 'cb' contains "unnamedplus" paste from "+ else if 'cb' contain "unnamed" paste from "* else paste from ""
In English, something like this.
If no register is specified, it depends on the 'cb' option. If 'cb' contains "unnamedplus", paste from the + register |quoteplus|. Otherwise, if 'cb' contains "unnamed", paste from the * register |quote_star|. Otherwise, paste from the unnamed register |quote_quote|.
> On Mon, Apr 23, 2012 at 02:57:58AM EDT, Gary Johnson wrote: > > On 2012-04-22, Chris Jones wrote: > > > On Sun, Apr 22, 2012 at 02:11:47PM EDT, Gary Johnson wrote:
> [..]
> > What are you, my English teacher? It's probably a defensive habit to > > give myself wiggle room. (Note the careful use of "probably" instead > > of "think".) You want to be my shrink, too? No offense taken. And > > none intended, honestly.
> :-)
> Forgive me... was in a ‘funny’ mood last night.. pixilated, perhaps..
No problem. As long as we're taking each other in good spirit. Or spirits.
> From a more general perspective, the OP could use the ‘autocutsel’ > program that keeps X11's clipboard & primary selection in sync'.
Inspired by this discussion, I decided to install autocutsel and see how that works out.
At work I have a Windows XP machine at my desk on which I run True X-Mouse to get something approximating X behavior on Windows. For development, I use NoMachine to display an X desktop (KDE) running on a Linux machine in the back room. With all those windowing systems and clipboard workarounds (True X-Mouse and autocutsel), it will be interesting to see if it all actually works together.
When I read this thread I used the published line:
set clipboard=unnamedplus,unnamed,autoselect,exclude:cons\|linux
I use Mac, Win, Linux and each has different a version of [g]vim.
This "set" failed differently on each.
I read more and found if vim is compiled with "xterm_clipboard"
then the default for clipboard is: "autoselect,exclude:cons\|linux"
Otherwise it is: ""
What could be causing a failure?
The only two other options, unnamed or unnamedplus.
It turned out to be unnamedplus, and as I recently learned...
rather than test for has() or exists() I could simply use "silent!".
Now, in the Linux I am using, anytime I select and yank, or just yank,
both "* and *+ are filled. Going to any other app and paste with C-v
or middle mouse button click works.
--AND--
To my surprise, if I copy with C-c from another app like a web
browser, then go back to [g]vim, p or P or :put or :put! work!
I have the following in .vimrc
it is used on Mac, Win, and Linux
works for all gvim, MacVim and terminal vim,
depending on the compiled options.
The vmap and nmap remain for vim versions that are not gui or do not
have xterm_clipboard compiled.
if has("clipboard")
vmap ,y "+y
nmap ,p "+gP
" exclude:{pattern} must be last ^= prepend += append
if has("gui_running") || has("xterm_clipboard")
silent! set clipboard^=unnamedplus
set clipboard^=unnamed
endif
endif
On Mon, Apr 23, 2012 at 06:07:24PM EDT, Gary Johnson wrote: > On 2012-04-23, Chris Jones wrote:
[..]
> > From a more general perspective, the OP could use the ‘autocutsel’ > > program that keeps X11's clipboard & primary selection in sync'.
> Inspired by this discussion, I decided to install autocutsel and see > how that works out.
Did the same but haven't looked into setting it up. Provided the tool works as I think it does, namely that from the user's perspective it makes the X clipboard and the PRIMARY selection behave as one, the question is, do I really want that..? IOW, what are the implications?
It looks as if all the OP wants is X11 to work like Microsoft Windows with just one single mechanism & clipboard..?
I rather dread revisiting these issues and fiddling with my environment at this point.. I have about ten pages of notes on the subject that would likely need to be updated.. I think I'll wait till I upgrade to 7.3 so I'm able to see for myself whether the new clipboard=unnamedplus option makes any difference.
X was designed by computer scientists.. maybe that's the problem.
> On Mon, Apr 23, 2012 at 06:07:24PM EDT, Gary Johnson wrote:
> > On 2012-04-23, Chris Jones wrote:
> [..]
> > > From a more general perspective, the OP could use the ‘autocutsel’
> > > program that keeps X11's clipboard & primary selection in sync'.
> > Inspired by this discussion, I decided to install autocutsel and see
> > how that works out.
> Did the same but haven't looked into setting it up. Provided the tool
> works as I think it does, namely that from the user's perspective it
> makes the X clipboard and the PRIMARY selection behave as one, the
> question is, do I really want that..? IOW, what are the implications?
> It looks as if all the OP wants is X11 to work like Microsoft Windows
> with just one single mechanism & clipboard..?
> I rather dread revisiting these issues and fiddling with my environment
> at this point.. I have about ten pages of notes on the subject that
> would likely need to be updated.. I think I'll wait till I upgrade to
> 7.3 so I'm able to see for myself whether the new clipboard=unnamedplus
> option makes any difference.
> X was designed by computer scientists.. maybe that's the problem.