Yanking doesn't yank

15 views
Skip to first unread message

Ottavio Caruso

unread,
Jan 12, 2023, 9:59:33 AM1/12/23
to v...@vim.org
[Originally sent through Gmane.io; apologies for possible duplicates]


I've been using Vim for almost 4 years now and I haven't got it right yet.

I have a block of text (say, 10 lines) that I want to copy from
somewhere to somewhere else.

I put the cursor on the first line, press capital v (shift + v); this
will highlight the line; then press down arrow until I have selected the
whole block. So far so good.

Then I press 'y'. If then I move the cursor down, it will still continue
to highlight the following text, which is not what I want.

As a workaround, after selecting text, I press 'd', then 'p' to but it
back where it was and then move down and press 'p' again.

I wonder why it will keep on selecting text after pressing 'y'.

I'm missing something obvious here.

My .vimrc.

$ cat .vim/vimrc
source $VIMRUNTIME/defaults.vim

"set shellcmdflag=-ic
set dir=~/.vim/tmp
set expandtab
set autoindent
set mouse=r

digraph bl 8226 " Insert Bullet with <CTRL>+k bl


iabbrev cwd <C-R>=strftime("%a %d/%m %H:%M")
iabbrev mydate <C-R>=strftime("%a %d/%m/%Y")
iabbrev mydate2 <C-R>=strftime("%Y%m%d")

map <f5> :1m$<cr>


--
Ottavio Caruso

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

jr

unread,
Jan 12, 2023, 10:18:22 AM1/12/23
to vim...@googlegroups.com
hi,

On Thu, 12 Jan 2023 at 14:59, 'Ottavio Caruso' via vim_use
<vim...@googlegroups.com> wrote:
> I have a block of text (say, 10 lines) that I want to copy from
> somewhere to somewhere else.
>
> I put the cursor on the first line, press capital v (shift + v); this ...
> ...

we all work differently :-). I do not use visual mode in that
situation, just note the line number of the first, then move to the
last line, and, eg, ':123,.y'.

--
regards, jr.

You have the right to free speech, as long as you're not dumb enough
to actually try it.
(The Clash 'Know Your Rights')

this email is intended only for the addressee(s) and may contain
confidential information. if you are not the intended recipient, you
are hereby notified that any use of this email, its dissemination,
distribution, and/or copying without prior written consent is
prohibited.

Tim Chase

unread,
Jan 12, 2023, 10:41:21 AM1/12/23
to 'Ottavio Caruso' via vim_use, v...@vim.org
On 2023-01-12 14:57, 'Ottavio Caruso' via vim_use wrote:
> Then I press 'y'. If then I move the cursor down, it will still
> continue to highlight the following text
[snip]
> I wonder why it will keep on selecting text after pressing 'y'.
[snip]
> source $VIMRUNTIME/defaults.vim

If you take out this defaults.vim line, does the issue persist? or
if you start vim with no vimrc?

$ vim -u NONE myfile.txt

It sounds either like the defaults.vim is interfering (and I'd
consider it to be doing so in a bad way).

I know that FreeBSD made some unforunate local changes a while back
and just finally (within the last couple months) got it resolved
so their systemwide vimrc didn't force me to use the defaults.vim
which did weird (breaking expectations from previous versions)
things. So I don't know if your system's defaults.vim (or a system
vimrc) might be causing issues.

If that doesn't resolve matters, I'd be curious what mappings show
up in play when you experience the issue since this Shouldn't
Happen(tm) with stock vim.

-tim






Gary Johnson

unread,
Jan 12, 2023, 12:09:24 PM1/12/23
to vim...@googlegroups.com
On 2023-01-12, Tim Chase wrote:

> If that doesn't resolve matters, I'd be curious what mappings show
> up in play when you experience the issue since this Shouldn't
> Happen(tm) with stock vim.

To see if y is mapped and where in Normal or Visual Line mode,
execute

:verbose map y

Regards,
Gary

Steve Litt

unread,
Jan 12, 2023, 5:54:25 PM1/12/23
to vim...@googlegroups.com
'Ottavio Caruso' via vim_use said on Thu, 12 Jan 2023 14:57:13 +0000

>[Originally sent through Gmane.io; apologies for possible duplicates]
>
>
>I've been using Vim for almost 4 years now and I haven't got it right
>yet.
>
>I have a block of text (say, 10 lines) that I want to copy from
>somewhere to somewhere else.
>
>I put the cursor on the first line, press capital v (shift + v); this
>will highlight the line; then press down arrow until I have selected
>the whole block. So far so good.
>
>Then I press 'y'. If then I move the cursor down, it will still
>continue to highlight the following text, which is not what I want.

I can't reproduce your symptom with my gvim version 9.0.948. My
highlighting vanishes when I press the y key. Just for fun, try using
the j key instead of the arrow key and see if the problem persists. The
j key means move down one line, and works with highlighting. The j key
is also faster for a touch typist than hunting and pecking the down
arrow. I'll say more later in this email.

>
>As a workaround, after selecting text, I press 'd', then 'p' to but it
>back where it was and then move down and press 'p' again.

I frequently do something like this when trying to yank the end of the
line. I press D and then p, and now I have the line ending in my
buffer.

>
>I wonder why it will keep on selecting text after pressing 'y'.

I don't know. Why don't you move your .vim/vimrc somewhere else and see
if it changes your symptom. If it does, you can work on your .vimrc
until you find the offending line. If the symptom is unchanged, you've
ruled out .vimrc. Also, as an additional data point, my .vimrc is in
my user directory (/home/slitt), not in /home/slitt/.vim . So be sure
to check your home directory for a .vimrc, because I have a feeling
you're approaching the wrong .vimrc.

>
>I'm missing something obvious here.
>
>My .vimrc.
>
>$ cat .vim/vimrc
>source $VIMRUNTIME/defaults.vim
>
>"set shellcmdflag=-ic
>set dir=~/.vim/tmp
>set expandtab
>set autoindent
>set mouse=r
>
>digraph bl 8226 " Insert Bullet with <CTRL>+k bl
>
>
>iabbrev cwd <C-R>=strftime("%a %d/%m %H:%M")
>iabbrev mydate <C-R>=strftime("%a %d/%m/%Y")
>iabbrev mydate2 <C-R>=strftime("%Y%m%d")
>
>map <f5> :1m$<cr>
>
>
>--
>Ottavio Caruso
>
>A: Because it messes up the order in which people normally read text.
>Q: Why is top-posting such a bad thing?
>A: Top-posting.
>Q: What is the most annoying thing in e-mail?
>
>--
>--
>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+u...@googlegroups.com. To view this discussion on the
>web visit
>https://groups.google.com/d/msgid/vim_use/CAEJNuHy8zJ8-kUiaYXKwW5%3D1Q06hzeor4Gu299VS-WW1nP26eQ%40mail.gmail.com.


SteveT

Steve Litt
Autumn 2022 featured book: Thriving in Tough Times
http://www.troubleshooters.com/bookstore/thrive.htm

Enan Ajmain

unread,
Jan 12, 2023, 10:52:20 PM1/12/23
to vim...@googlegroups.com
On Thu, 12 Jan 2023 17:54:09 -0500
Steve Litt <sl...@troubleshooters.com> wrote:
> I frequently do something like this when trying to yank the end of the
> line. I press D and then p, and now I have the line ending in my
> buffer.

Unrelated to OP's question, but you, Steve, can simplify this workflow
with:
:noremap Y y$

Otherwise, with 'Dp', you're tarnishing the undotree unnecessarily.


--
Enan
3nan....@gmail.com
https://git.sr.ht/~enan/
https://www.github.com/3N4N

Ottavio Caruso

unread,
Jan 13, 2023, 5:22:24 AM1/13/23
to vim...@googlegroups.com
Am 12/01/2023 um 15:41 schrieb Tim Chase:
> If you take out this defaults.vim line, does the issue persist? or
> if you start vim with no vimrc?
>
> $ vim -u NONE myfile.txt
>
> It sounds either like the defaults.vim is interfering (and I'd
> consider it to be doing so in a bad way).

I've loaded the file with

$ vim -u NONE file

and the issue persists.

It still selects even after pressing 'y'.

Ottavio Caruso

unread,
Jan 13, 2023, 5:27:35 AM1/13/23
to vim...@googlegroups.com
Thanks for that, Gary.

I'm officially an idiot.

I switched my keyboard layout to QWERTZ and, obviously, the 'y' was
remapped to 'z'.

Sorry for the noise. Have mercy. Pray for me.

aro...@vex.net

unread,
Jan 13, 2023, 9:18:47 AM1/13/23
to vim...@googlegroups.com

>
> Thanks for that, Gary.
>
> I'm officially an idiot.
> --
> Ottavio Caruso
>

At least you're an honest one. :-)*
Welcome to the Order of the Golden Face-Palm, which I think we all earn at
one time or another. Confession and explanation improves collective
wisdom.

Reply all
Reply to author
Forward
0 new messages