Quantcast

Pasting from wrong register(?)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Pasting from wrong register(?)

Fabian Furger
Hi,

I frequently get bugged when pasting over a visually selected block of text and the default register contains the deleted text afterwards - chances are, I want to paste the same text multiple times.

A while ago I found a convenient map to get around that by replacing the content of the default register:

`vnoremap P p:call setreg('"', getreg('0'))<CR>`

That worked fine in terminal vim 7.3 (the version in Ubuntu 14.04 LTS) but doesn't seem to work on my own machine (terminal vim 8 on ArchLinux).
Checking with `:reg "`, I see that it does indeed contain the right content, but when pasting, it appears that the contents of the last selection register `"*` is used instead - I'd need to explicitly paste from the unnamed register `""p`.

Do I misunderstand something or am I doing something wrong?

Thanks in advance

--
--
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 received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pasting from wrong register(?)

Bee-16
On Friday, December 30, 2016 at 12:28:49 PM UTC-8, Fabian Furger wrote:
> A while ago I found a convenient map to get around that by replacing the content of the default register:
>
> `vnoremap P p:call setreg('"', getreg('0'))<CR>`

Does the following work in both cases?

vnoremap P "0P

--
--
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 received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pasting from wrong register(?)

Fabian Furger
On Friday, 30 December 2016 22:52:41 UTC+1, Bee  wrote:
> Does the following work in both cases?
>
> vnoremap P "0P

Well, that kind of works even if it's not what I'm looking for - because after such a "replace" pasting with P in visual mode, I still lose the original content of the default register, so I can't do normal mode pasting (only visual mode).

I used to think that when not specifying the register, the default register is used - which apparently isn't the case like I described initially. Was this behavior changed at some point, is my thinking wrong, or may that be a bug?

--
--
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 received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pasting from wrong register(?)

Christian Brabandt
In reply to this post by Fabian Furger
On Fr, 30 Dez 2016, Fabian Furger wrote:

> A while ago I found a convenient map to get around that by replacing the
> content of the default register:
>
> `vnoremap P p:call setreg('"', getreg('0'))<CR>`
>
> That worked fine in terminal vim 7.3 (the version in Ubuntu 14.04 LTS) but
> doesn't seem to work on my own machine (terminal vim 8 on ArchLinux).
> Checking with `:reg "`, I see that it does indeed contain the right content,
> but when pasting, it appears that the contents of the last selection register
> `"*` is used instead - I'd need to explicitly paste from the unnamed register
> `""p`.
>
> Do I misunderstand something or am I doing something wrong?

What is your 'clipboard' setting?

Best,
Christian
--
Objektivität: Alles hat zwei Seiten. Aber erst wenn man erkennt, daß
es drei sind, erfaßt man die Sache.
                -- Heimito von Doderer

--
--
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 received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pasting from wrong register(?)

Fabian Furger
I'm setting clipboard to unnamed. I can't claim to fully understand yet how this (and related) options work so I played around a bit and found that it works when I have the `exclude:` part of the default clipboard value (not /etc/vimrc). That explains why it was working on the other machine (with the same configuration) - there was no X server to share a clipboard with.

To me, it seems like the best solution is to set the clipboard to `unnamedplus` and change the map to replace the `+`-register instead of the `"`-register - using the plus instead of the star register because the star register gets overwritten when selecting the text I'm trying to replace.

Thanks and a happy new year everyone!

On 31 December 2016 at 11:54, Christian Brabandt <[hidden email]> wrote:
On Fr, 30 Dez 2016, Fabian Furger wrote:

> A while ago I found a convenient map to get around that by replacing the
> content of the default register:
>
> `vnoremap P p:call setreg('"', getreg('0'))<CR>`
>
> That worked fine in terminal vim 7.3 (the version in Ubuntu 14.04 LTS) but
> doesn't seem to work on my own machine (terminal vim 8 on ArchLinux).
> Checking with `:reg "`, I see that it does indeed contain the right content,
> but when pasting, it appears that the contents of the last selection register
> `"*` is used instead - I'd need to explicitly paste from the unnamed register
> `""p`.
>
> Do I misunderstand something or am I doing something wrong?

What is your 'clipboard' setting?

Best,
Christian
--
Objektivität: Alles hat zwei Seiten. Aber erst wenn man erkennt, daß
es drei sind, erfaßt man die Sache.
                -- Heimito von Doderer

--
--
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 received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/FfKUA2Xgx_Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
--
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 received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Pasting from wrong register(?)

Tony Mechelynck
On Sat, Dec 31, 2016 at 6:27 PM, Fabian Furger <[hidden email]> wrote:

> I'm setting clipboard to unnamed. I can't claim to fully understand yet how
> this (and related) options work so I played around a bit and found that it
> works when I have the `exclude:` part of the default clipboard value (not
> /etc/vimrc). That explains why it was working on the other machine (with the
> same configuration) - there was no X server to share a clipboard with.
>
> To me, it seems like the best solution is to set the clipboard to
> `unnamedplus` and change the map to replace the `+`-register instead of the
> `"`-register - using the plus instead of the star register because the star
> register gets overwritten when selecting the text I'm trying to replace.
>
> Thanks and a happy new year everyone!
>
Happy New Year. With Vim, there is usually no "best" one-size-fits-all
solution. I use the value "exclude:cons\|linux" (which would come from
":set cb=exclude:cons\\\|linux") but I can't find where my vimrc sets
that value. When I want Vim to change the * and/or + register I do it
explicitly, otherwide I leave well enough alone.

Best regards,
Tony.

--
--
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 received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...