Monday, March 2, 2015

Re: Visual yank

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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: