after vim 8 installation, yanking (yy) doesn't work in global command and macros

413 views
Skip to first unread message

Bryce Orgill

unread,
Nov 4, 2016, 12:03:00 AM11/4/16
to vim_use
After I installed the Vim 8 version, I noticed that the following command doesn't yank the current line for every line it's supposed to run on.

%g/^/normal yyp

When I run it, it pastes whatever was previously copied. When I run "normal yyp", this works fine, it just doesn't seem to work in global commands and in macros. Here is my example:

Example:
-----------
string currently stored in clipboard: 7777
command given: %g/^/normal yyp
original text:
1234
5678

new text (actual output):
1234
7777
5678
7777

new text (expected output):
1234
1234
5678
5678

This seems like a real bug as I never experienced this in earlier versions.

Bryce

Christian Brabandt

unread,
Nov 4, 2016, 3:03:31 AM11/4/16
to vim_use
Hi Bryce!
Cannot reproduce. What is your clipboard setting? Can you please narrow
down the problem when starting vim like this vim -u NONE -N --noplugins


Best,
Christian
--
Eine Gesellschaft, die sich mehr leistet, als sie sich leisten kann,
nennt man Leistungsgesellschaft.
-- Werner Mitsch

h_east

unread,
Nov 4, 2016, 1:10:48 PM11/4/16
to vim_use
Hi ChrisBra and All,

2016-11-4(Fri) 16:03:31 UTC+9 Christian Brabandt:

A little supplement:
s/--noplugins/--noplugin/
When you specify the `-u NONE`, it will treat you also specify `--noplugin` and `-U NONE`.

Please see `:h -u` and `:h --noplugin`
> When {vimrc} is equal to "NONE" (all uppercase), all
> initializations from files and environment variables are
> skipped, including reading the |gvimrc| file when the GUI
> starts. Loading plugins is also skipped.

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

Bryce Orgill

unread,
Nov 4, 2016, 3:21:12 PM11/4/16
to vim_use
I found the issue is present on both my work computer (Windows 7) and home computer (Windows 10) for version 8.0. I don't see the issue on my Android phone (also version 8.0) but this runs in a unix emulator called Termux. So I think the issue may only reside on the windows side. I do find in windows that it affects both the GVIM and VIM applications.

I did do some more investigating and when I run with no plugins, the issue is gone, so the yanking in the global command works. I narrowed down the issue to the clipboard setting (set clipboard). By default, this is blank but in my vimrc file, I set it to "unnamed". I need this setting because it allows me to copy something in VIM and it will be available in apps external to VIM (placed on windows clipboard). So when I run VIM without plugins, the yanking works, but right when I set that clipboard setting to unnamed, the yanking doesn't work anymore.

This was working on previous versions like 7.4, 7.3, 7.2. So I'm not sure why it would stop working now.

Bryce

Christian Brabandt

unread,
Nov 4, 2016, 4:19:03 PM11/4/16
to vim_use
Hi Bryce!
The clipboard setting is explicitly disabled for :g commands.


Best,
Christian
--
Wer die Zukunft als Gegenwind empfindet, geht in die falsche Richtung.
-- Martin Held

Bryce Orgill

unread,
Nov 4, 2016, 4:35:19 PM11/4/16
to vim_use
Was that a change that was put in version 8? In my opinion that is a big change. It now means I can't yank in the global command or in macros. I have macros and scripts that use this. It means it won't work there. I have to also use the 'set clipboard=unnamed' command to be able to copy/paste from/to vim to/from other apps. I'm not sure why this change was taken out of version 7.4. It was working fine there and in previous versions. Why does this work in Unix but not Windows?

In my opinion this needs to be fixed. I don't see a work around in my current status, which means I'd have to revert back to 7.4 to keep my scripts working.

Bryce

Christian Brabandt

unread,
Nov 4, 2016, 4:43:08 PM11/4/16
to vim_use
Hi Bryce!

On Fr, 04 Nov 2016, Bryce Orgill wrote:

> Was that a change that was put in version 8? In my opinion that is a big change. It now means I can't yank in the global command or in macros. I have macros and scripts that use this. It means it won't work there. I have to also use the 'set clipboard=unnamed' command to be able to copy/paste from/to vim to/from other apps. I'm not sure why this change was taken out of version 7.4. It was working fine there and in previous versions. Why does this work in Unix but not Windows?
>
> In my opinion this needs to be fixed. I don't see a work around in my current status, which means I'd have to revert back to 7.4 to keep my scripts working.

This was changed in 7.4.396 for performance reasons. It should be
possible to explicitly paste from the clipboard using "+p

Best,
Christian
--
"Ich fühle mich richtig schlapp und schwach", meint der Elefant
traurig. Daraufhin meint ein anderer Elefant:
"Man spürt es eben doch, daß man aus einer Mücke gemacht wird."

Andy Wokula

unread,
Nov 4, 2016, 4:53:13 PM11/4/16
to vim...@googlegroups.com
Then:
:set cb=unnamed
Within :global, `yy' yanks into the clipboard and `p' puts from the clipboard.

Now:
:set cb=unnamed
Within :global, `yy' does not yank into the clipboard, but `p' still puts from the clipboard.
Looks like `yy' fails to set the last used register (`0').

Workaround:
:g/^/normal! yy"0p

(register `0' contains the yanked text even with cb=unnamed).

--
Andy

Bryce Orgill

unread,
Nov 4, 2016, 5:18:30 PM11/4/16
to vim_use
This is a bug in my opinion. Maybe not a bug on accident but bad design. The whole point of Vim is less key strokes. This means, I'm going to have to get use to the idea of typing yy"0p or something equivalent everytime I use the global. The "yy" and "p" go together like peanut butter and jelly. It just doesn't make sense to disconnect these in a global command. What if I forget and I go on manipulating my file and don't see that I mistakenly typed (but ideally should be) yyp. Others will likely run into this error as well.

Bryce Orgill

unread,
Nov 4, 2016, 5:33:09 PM11/4/16
to vim_use
Here's another idea. I don't mind the disabling of the clipboard when using the yanking in the global command. But is there a way that yyp can pick up on the same register during this command so the paste picks up what was yanked? I don't know, something to think about. Or is there an additional setting that would allow you to use the clipboard setting during global that could be set up?

Bryce Orgill

unread,
Nov 4, 2016, 9:18:37 PM11/4/16
to vim_use
Can someone tell me why this macro (:g/-/normal @q) doesn't work now on version 8, when it worked on 7.4? I'm guessing it's related to the yanking thing. Even when I replace the @+ to @0 it still doesn't work.

€kh/-^M€klviw^C:let y1=@+^Mn€krviw^C:let y2=@+^M:let y3=y2-y1^M:let @a=y3^M:let @b=line(".")^M€kh/-^M€*7€kbmayy:normal ^Rap^M:normal ^Raj^M€kumb:'a,'bs/:\zs\d\+/\=y1+line(".")-^Rb/^M

Bram Moolenaar

unread,
Nov 5, 2016, 5:33:49 PM11/5/16
to vim...@googlegroups.com
Should be easy to fix: when Vim does "yy" and the clipboard isn't updated
because it's in a global command, then the next "p" should use what
would have been put on the clipboard.

Unfortunately I can't reproduce the problem... Does this only happen on
MS-Windows?

--
Female engineers become irresistible at the age of consent and remain that
way until about thirty minutes after their clinical death. Longer if it's a
warm day.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bryce Orgill

unread,
Nov 6, 2016, 12:18:31 AM11/6/16
to vim_use
Yes, I've only seen this issue on MS-Windows (both Windows 7 and Windows 10). I don't see the issue on Unix, but I'm testing that with a Unix emulator on my Android phone called Termux, which was tested with version 8.

BrycW

Reply all
Reply to author
Forward
0 new messages