Visual yank

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Visual yank

kouzennoki
Hey,

I was surprised to find that a visual yank (select a piece of a line of text, press y to yank) will copy not only the text that is visually selected, but also the one character under the cursor.

So for instance you have this text selected up to the period. But the text also includes the space when you visually select it using "v" and then copy it into the default register.

And pasting it then reveals the additional space. I had pasted using "0P.

Is this expected or wanted or default behaviour? Should I be dealing with this, ie. always select one character less than what I want? Or is it a bug of some kind?

Please advise.

Regards,

D.

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

Re: Visual yank

Sven Guckes-3
* Dryden <[hidden email]> [2015-03-02 15:39]:
> I was surprised to find that a visual yank (select a piece of a line
> of text, press y to yank) will copy not only the text that is
> visually selected, but also the one character under the cursor.

well.. why should a selected character NOT be included by a copy?

> So for instance you have this text selected up to the period.
> But the text also includes the space when you visually select
> it using "v" and then copy it into the default register.

sorry.. it's an unclear example.

> And pasting it then reveals the additional space. I had pasted using "0P.

maybe you didnt see that the cursor was on the space
so it had been included in the copy (as expected)?

> Is this expected or wanted or default behaviour?
> Should I be dealing with this, ie. always select
> one character less than what I want?
> Or is it a bug of some kind?
> Please advise.

well.. which version are you using on which system?
and can you give a reproducible example?

Sven

--
:ver
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 25 2015 02:12:47)
Inklusive der Korrekturen: 1-591
$ uname -a
Linux kudu.in-berlin.de 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u2 x86_64 GNU/Linux

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

Re: Visual yank

Benjamin Fritz
In reply to this post by kouzennoki
On Monday, March 2, 2015 at 8:35:56 AM UTC-6, Dryden wrote:

> Hey,
>
> I was surprised to find that a
>  visual yank (select a piece of a line of text, press y to yank) will
> copy not only the text that is visually selected, but also the one
> character under the cursor.
>
> So for instance you have this
> text selected up to the period. But the text also includes the space
> when you visually select it using "v" and then copy it into the default
> register.
>
> And pasting it then reveals the additional space. I had pasted using "0P.
>
> Is
>  this expected or wanted or default behaviour? Should I be dealing with
> this, ie. always select one character less than what I want? Or is it a
> bug of some kind?
>
> Please advise.
>
>
Wow, I think I *finally* understand the purpose of the 'selection' option.

It sounds like you're expecting that after you select some text, the selected text doesn't include the cursor. I.e. you're expecting that the selection only includes the text the cursor moved over. For that to be the case, you need to ":set selection=exclusive". The default value of the selection option is "inclusive", meaning that the visual selection also includes the cursor location.

I've had a hard time figuring out why anyone would ever *want* the selection not to include the "last character" as mentioned in ":help 'selection'". Thinking of it as the cursor instead means the option actually makes some sense...

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

Re: Visual yank

kouzennoki
Hi, I am sorry, I am not able to reproduce it anymore :( :-/.

I was just regularly editing a bash script on a Kubuntu system, nothing special.

It seemed as if the cursor was /ahead/ of the selection, but when I try again now, it is within the selection.

I have done it at least 3 times. I wanted to make sure, and also to learn how to do it best next time, with the least amount of work. For that reason I went back several times to see what I was doing wrong.

I can't reproduce it. Very odd. The 'selection' option actually indeed caused the final character (that is now simply within the visual selection) to not be copied, which is not what I want ;-).

In any case, perhaps it will happen again some time, I will be sure to be more attentive that time. Regards,

D.



On Mon, Mar 2, 2015 at 3:51 PM, Ben Fritz <[hidden email]> wrote:

Wow, I think I *finally* understand the purpose of the 'selection' option.

It sounds like you're expecting that after you select some text, the selected text doesn't include the cursor. I.e. you're expecting that the selection only includes the text the cursor moved over. For that to be the case, you need to ":set selection=exclusive". The default value of the selection option is "inclusive", meaning that the visual selection also includes the cursor location.

I've had a hard time figuring out why anyone would ever *want* the selection not to include the "last character" as mentioned in ":help 'selection'". Thinking of it as the cursor instead means the option actually makes some sense...

--
--
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.

--
--
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.