Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1401410 - f24->f25 vim: copy paste no longer works
Summary: f24->f25 vim: copy paste no longer works
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: vim
Version: 25
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Matthias Clasen
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1382426 1405934 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-05 07:55 UTC by Ryan Rowe
Modified: 2017-02-28 14:27 UTC (History)
16 users (show)

Fixed In Version: vim-8.0.133-2.fc25 vim-8.0.142-1.fc25 vim-8.0.142-1.fc24
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-01-05 20:22:12 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Ryan Rowe 2016-12-05 07:55:03 UTC
Description of problem:
I am using vim in gnome-terminal. Since upgrading to F25, copy/paste no longer works.


Version-Release number of selected component (if applicable):
vim-enhanced-8.0.118-1.fc25.x86_64

How reproducible:
Every time

Steps to Reproduce:
1. vi testfile
2. insert some text
3. select it with the mouse
4. middle-click in gedit to paste OR go to edit> copy in gnome-terminal

Actual results:
nothing happens / no copy option in gnome-terminal


Expected results:
paste


Additional info:

Comment 1 Ryan Rowe 2016-12-05 08:07:47 UTC
Possibly related to bug 1400088 and bug 1400477

Comment 2 Zdenek Dohnal 2016-12-05 11:10:00 UTC
Hi Ryan,

it really seems it is not vim bug, because I have the same vim version on F24 and Copy/Paste works there. What I found out so far:

1) When you select some text with mouse, VIM goes into Visual mode automatically.

2) Copy/Paste works in certain way, when you select text and click on place, where you want to paste text, with mouse middle button. But it works only for same opened file, you cannot copy/paste out of vim.

I will reassign it to gnome-terminal.

Comment 3 Zdenek Dohnal 2016-12-05 19:18:45 UTC
When I completely upgrade OS to Fedora 25, behavior described in comment #2 mostly disappeared. I can select block of text without going into visual mode and I can use Edit->Copy from menu. Only thing, which appeared, is when I selected block of text and clicked on mouse middle button, it automatically goes into insert mode and pastes selected text after cursor. I do not know if this is correct behavior.

Comment 4 Egmont Koblinger 2016-12-05 21:01:03 UTC
Could you please clarify the description? In bullet point 4 you say "edit >copy" in gnome-terminal doesn't paste... not sure why "copy" would "paste".

Three things to look at / be aware of:

- The usual confusion between PRIMARY and CLIPBOARD in X11, or if Wayland is used then I have no clue how it goes there.

- Whether VIM handles mouse events on its own rather than letting gnome-terminal select text. You could test it by a single right-click: Does it bring up gnome-terminal's context menu? Also what happens if you highlight the text with Shift+click instead of simple click?

- VIM might enable "bracketed paste mode" in which case the characters that are pasted are enclosed between special marks. This makes it possible for VIM to handle them differently than if they were typed at the keyboard, e.g. automatically switch to insert mode rather than executing various (presumably unintended) commands.

Comment 5 Ryan Rowe 2016-12-06 10:30:07 UTC
> Could you please clarify the description? In bullet point 4 you say "edit >copy" in gnome-terminal doesn't paste... not sure why "copy" would "paste".

I never say that copy would paste, I describe two differences I encounter since upgrading from F24 to F25.

Difference 1:
(select some text then...)
middle-click in gedit to paste -> nothing happens

Difference 2:
(select some text then...)
go to edit> copy in gnome-terminal -> you can't. copy is grayed out.

> The usual confusion between PRIMARY and CLIPBOARD in X11, or if Wayland is used then I have no clue how it goes there.

This is covered by the two test cases shown above in this comment.

> - Whether VIM handles mouse events on its own rather than letting gnome-terminal select text. You could test it by a single right-click: Does it bring up gnome-terminal's context menu?

It does not bring up gnome-terminal's context menu.

Comment 6 Egmont Koblinger 2016-12-06 10:35:34 UTC
(In reply to Ryan Rowe from comment #5)

> It does not bring up gnome-terminal's context menu.

This means that VIM handles the mouse events (click, drag etc.). If the "selected" characters are visually highlighted (e.g. inverted), it's done by VIM manually.

From gnome-terminal's point of view, there's no copy operation whatsoever going on. It only reports mouse events to VIM, just as e.g. it would report them to MC or any other mouse-aware app.

Use Shift+Click to override and make a selection in gnome-terminal. Or disable mouse support in your VIM.

This is the intended behavior.

Comment 7 Ryan Rowe 2016-12-07 12:14:28 UTC
It is not intended behavior if it is an undocumented change, I will re-assign to vim.

Comment 8 Karsten Hopp 2016-12-07 15:25:00 UTC
What's the output of  :set mouse?
Please have a look at :help mouse   and try the different settings. Which one gives you the expected behaviour ?

Comment 9 Ryan Rowe 2016-12-07 19:02:49 UTC
Wait a second... shift click brings up the gt-t menu, but I still can't choose Copy, it's grayed out. Same as Edit> Copy is grayed out.

> What's the output of :set mouse?
mouse = a

> Please have a look at :help mouse   and try the different settings. Which one gives you the expected behaviour ?
set mouse=v
seems good.

Comment 10 Egmont Koblinger 2016-12-07 19:48:15 UTC
(In reply to Ryan Rowe from comment #9)
> Wait a second... shift click brings up the gt-t menu, but I still can't
> choose Copy, it's grayed out. Same as Edit> Copy is grayed out.

You need to make your selection with with Shift+click. Otherwise it's VIM that handles the click+drag events and not gnome-terminal itself creating a selection.

Comment 11 Greta Watson 2016-12-12 05:38:38 UTC
I am running Fedora 24, kernel 4.8.12-200.fc24.x86_64, KDE spin.

When vim-enhanced, vim-common, vim-filesystem, and vim-minimal were updated from 2:7.4.1718-1.fc24.x86_64 to 2:8.0.124-2.fc24.x86_64, the behavior of paste using the middle mouse button changed when vim was invoked from the command line.

In the earlier version, clicking the middle button would copy the contents of the clipboard into the file that vim was dealing with, at the specified insert location.

In the later version, the clipboard would not be copied.  Instead, one blank character would be copied.

However, by running the later version in the compatible mode (vim -C), the contents of the clipboard are copied.

The behavior of /bin/vi did not change--it continues to copy the clipboard.

Comment 12 Zdenek Dohnal 2016-12-13 07:51:35 UTC
Hi Greta,

would you mind trying to set mouse=v, if it helps? Like Ryan said in comment #9?

Comment 13 Greta Watson 2016-12-13 21:04:47 UTC
set mouse=v works.
shift click (with or without set mouse=v) also works.

Comment 14 Fedora Update System 2016-12-15 17:07:43 UTC
vim-8.0.133-2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-ac0548af76

Comment 15 Fedora Update System 2016-12-15 17:09:11 UTC
vim-8.0.133-2.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-ed409d5de3

Comment 16 Fedora Update System 2016-12-16 05:32:01 UTC
vim-8.0.133-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-ac0548af76

Comment 17 Fedora Update System 2016-12-16 05:34:05 UTC
vim-8.0.133-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-ed409d5de3

Comment 18 Fedora Update System 2016-12-16 21:01:58 UTC
vim-8.0.133-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 19 Greta Watson 2016-12-17 00:23:13 UTC
In Fedora 24, I updated vim-common, vim-minimal, vim-enhanced, and vim-filesystem to 8.0.133-2.fc24.x86_64.  /etc/vimrc has the line:  set mouse=v.

However, when I invoke vim, and set mouse, the value is "a" rather than "v".  What else do I need to do?

I can still get it to work by invoking "vim -C", using shift click, or manually setting mouse=v.

Comment 20 Eric Work 2016-12-17 09:03:11 UTC
This change effectively breaks gvim for the normal usage pattern.  You can no longer use the mouse to move the cursor.  It only selects text now.  Reading the docs I guess that would make sense since mouse=v makes it behave like visual mode only which before only happened when you dragged.  It doesn't work in insert mode like mouse=a did before which positions the cursor with a single click.  In fact upon further testing console vim behaves almost the same as a GNOME vim does now when mouse=a.  If you set mouse=a and then use "+y, followed by "+p then you can copy and paste to the system clipboard just like GNOME vim would.  In fact if I unset mouse=a in /etc/vimrc it does exactly what the default behavior is as documented in vim and does the right thing in both console vim and gvim.

'mouse'                 string  (default "", "a" for GUI, MS-DOS and Win32,
                                                 set to "a" in defaults.vim)

I'm actually wondering why others were having a problem with this before.  As far as I can remember after doing a dnf system upgrade from F24 to F25 I wasn't having a problem until now.  If someone here is having the problem still and hasn't upgraded the vim package yet can they try ":set mouse" in vim and see what it reports?

Comment 21 Paul Wouters 2016-12-17 18:22:45 UTC
any combination of vim -C or vim with /etc/vimrc containing no mouse line, set mouse=v or set mouse=a causes the same broken failure of copy&paste.

This is on fedora 25 with 8.0.133-2 of all vim packages involved.

Using :set mouse=v inside vim does seem to work around it

Comment 22 Paul Wouters 2016-12-17 18:25:35 UTC
note creating a ~/.vimrc just containing set mouse=v is a workaround that does work. So it seems perhaps the setting in /etc/vimrc is lost or not read properly

(i did not have a .vimrc before creating it with this workaround)

Comment 23 Eric Work 2016-12-17 18:40:53 UTC
For people who are having issues with console vim you can create a ~/.vimrc with "set mouse=" which will make it behave like the expected vim default setting and copy/paste works.  Although if you do this it will break cursor position in gvim unless you create ~/.gvimrc with "set mouse=a" as well.  I have both a ~/.vimrc and ~/.gvimrc and neither has any mouse settings and I was getting the default vim behavior until this recent change in /etc/vimrc.  If people don't have ~/.vimrc files and were before getting mouse=a in console vim that's quite strange.

Although in /usr/share/vim/vim80/defaults.vim I see:

if has('mouse')
  set mouse=a
endif

So this makes me think some terminal emulators are reporting a mouse is present while others are not maybe?  Do you guys happen to be running wayland?  I play games occasionally so I have the official nvidia driver installed and I'm still running Xorg using gnome-terminal.

Comment 24 Dario Lesca 2016-12-18 10:55:02 UTC
On my Fedora 25 I have update now to vim-*-8.0.133-2.fc25.x86_64

[lesca@dodo ~]$ LANG=C vim --version|head -2
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 15 2016 16:47:44)
Included patches: 1-133

with this changelog:

[lesca@dodo ~]$ rpm -q vim-minimal --changelog|head -3
* gio dic 15 2016 Zdenek Dohnal <zdohnal> - 2:8.0.133-2
- f24->f25 vim: copy paste no longer works (bug #1401410) - change mouse default setting to 'v'

The mouse problem still exist and the mouse setting still to be =a

[lesca@dodo ~]$ grep set\ mouse !$
grep set\ mouse /usr/share/vim/vim80/defaults.vim
  set mouse=a

Without "echo 'set mouse=' >> ~/.vimrc", the copy/paste mouse action, when use vim into mate-terminal, not work property

IMHO, modify the "set mouse=a" line into /usr/share/vim/vim80/defaults.vim, and set it to "set mouse=" or "set mouse=v"

Create a .vimrc files for my and root users (sudo vim /etc/...) on all my Fedora Workstation and server is an annoying job

Comment 25 Ahmad Samir 2016-12-18 13:08:12 UTC
This is a change in vim 8* (since patch 7.4.2111); now when no ~/.vimrc file is found the defaults.vim (/usr/share/vim/vim80/defaults.vim) script is used; which has 'mouse=a'.

defaults.vim is loaded after /etc/vimrc from [1]:
Patch 7.4.2319
Problem:    No way for a system wide vimrc to stop loading defaults.vim.
            (Christian Hesse)
Solution: Bail out of defaults.vim if skip_defaults_vim was set.


so it overrides values set in /etc/vimrc.

[1] https://github.com/vim/vim/blob/5162822914372fc916a93f85848c0c82209e7cec/runtime/doc/version8.txt#L14219

https://github.com/vim/vim/blob/5162822914372fc916a93f85848c0c82209e7cec/runtime/doc/starting.txt#L1038

Comment 26 Dario Lesca 2016-12-19 00:03:59 UTC
Where I must set 'skip_defaults_vim'?
Into /etc/vimrc ? ... or into my ~/.vimrc? .. or into some other place?

The goal is restore the previous mouse behaviour. Without forcing all users to change all their systems, and this can be done only by releasing a specific patch to vim or its default configuration files...

Why it's not possible release a defaults.vim with "set mouse=v" or "set mouse=" ?

... or did I miss something?

Thanks.
Dario

Comment 27 Zdenek Dohnal 2016-12-19 06:51:17 UTC
Hi,

I deeply apologize for problems, I am new co-maintainer of VIM and I thought putting set mouse=v into /etc/vimrc will solve issue. I will quickly create new build with Dario's suggestion (putting it into defaults.vim) and update it.

Comment 28 Eric Work 2016-12-19 07:25:36 UTC
I would suggest something like the following not to break gvim:

if !has("gui_running")
  set mouse=
endif

Comment 29 Zdenek Dohnal 2016-12-19 07:36:22 UTC
Erik,

are you suggesting that we should leave:

if has('mouse')
  set mouse=a
endif

as it is now and only add after that your suggestion:

if !has("gui_running")
  set mouse=
endif

Comment 30 Eric Work 2016-12-19 07:46:17 UTC
OK... according to strace /etc/vimrc is always read and it's read first.  If ~/.vimrc is present then defaults.vim is not read.  Basically one or the other.  I think I see the problem now and I can reproduce it.  You just need to remove the following block from defaults and it should work like it's suppose to:

" In many terminal emulators the mouse works just fine.  By enabling it you
" can position the cursor, Visually select and scroll with the mouse.
if has('mouse')
  set mouse=a
endif

If you have a ~/.vimrc file it won't mess with the mouse and that's why it worked for me until /etc/vimrc was changed.  GNOME terminal must support mouse reporting which is why this triggers without a ~/.vimrc.  If you did not have ~/.vimrc and this mouse setting was removed it will be like default again, mouse=a for gui and mouse= for console.

1. Remove the mouse line added to /etc/vimrc
2. Remove the above block from defaults.vim

Now the mouse is not messed with and the defaults makes everyone happy again.  Normal select and middle click work in the terminal and gvim you can still click to move the cursor and drag to copy/paste.

Comment 31 Zdenek Dohnal 2016-12-19 07:51:06 UTC
Ok, thank you very much, Eric. Builds will be in 15 minutes with your suggested changes and I will put here links to koji, where everybody can download it and install it now, without waiting for update.

Comment 32 Fedora Update System 2016-12-19 08:25:50 UTC
vim-8.0.134-2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-0281ab71ff

Comment 34 Fedora Update System 2016-12-19 08:31:34 UTC
vim-8.0.134-2.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-be5fa630c5

Comment 35 Dario Lesca 2016-12-19 09:16:48 UTC
I have download and install this new package on a f25 test system and the mouse into a gnome-terminal work like expected.

[lesca@linux140 ~]$ vim --version |head -2
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 19 2016 08:17:13)
Patch incluse: 1-134

[lesca@linux140 ~]$ grep mouse= /usr/share/vim/vim80/defaults.vim
[lesca@linux140 ~]$ grep mouse= /etc/vimrc 

Thank to all.
Dario

Comment 36 Zdenek Dohnal 2016-12-19 09:24:42 UTC
*** Bug 1405934 has been marked as a duplicate of this bug. ***

Comment 37 Karsten Hopp 2016-12-19 09:46:21 UTC
(In reply to Zdenek Dohnal from comment #27)
> Hi,
> 
> I deeply apologize for problems, I am new co-maintainer of VIM and I thought
> putting set mouse=v into /etc/vimrc will solve issue. I will quickly create
> new build with Dario's suggestion (putting it into defaults.vim) and update
> it.

That was a change that Zdenek discussed with me (the 'main' VIM maintainer) before doing the update and we agreed on this workaround. I didn't notice that defaults.vim would overwrite settings from the vimrc, what's the point of that upstream change anyway ? 

Thanks for all that valuable feedback and your suggestions for a better fix. Please test Zdenek's latest update and give feedback if mouse behaviour is still wrong in either gvim or vim.

Comment 38 Ahmad Samir 2016-12-19 10:50:11 UTC
(In reply to Dario Lesca from comment #26)
> Where I must set 'skip_defaults_vim'?
> Into /etc/vimrc ? ... or into my ~/.vimrc? .. or into some other place?
>

In /etc/vimrc at the top:
let skip_defaults_vim=1

(if you have a ~/.vimrc defaults.vim isn't loaded at all anyway).


(In reply to Karsten Hopp from comment #37)
> (In reply to Zdenek Dohnal from comment #27)
> > Hi,
> > 
> > I deeply apologize for problems, I am new co-maintainer of VIM and I thought
> > putting set mouse=v into /etc/vimrc will solve issue. I will quickly create
> > new build with Dario's suggestion (putting it into defaults.vim) and update
> > it.
> 
> That was a change that Zdenek discussed with me (the 'main' VIM maintainer)
> before doing the update and we agreed on this workaround. I didn't notice
> that defaults.vim would overwrite settings from the vimrc, what's the point
> of that upstream change anyway ? 
> 

IMHO, I agree what's the point of having defaults that only affect users who don't have a ~/.vimrc? /etc/vimrc is loaded even with a ~/.vimrc, and one can override individual settings in ~/.vimrc.

I suggest to discard all the settings from defaults.vim by adding:
let skip_defaults_vim=1

at the top of /etc/vimrc (with a comment explaining the issue).

Then you can look at the upstream default settings in defaults.vim, if there's something useful as a default that /etc/vimrc doesn't already have then add it to /etc/vimrc.

Comment 39 Fedora Update System 2016-12-20 00:59:43 UTC
vim-8.0.134-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0281ab71ff

Comment 40 Fedora Update System 2016-12-20 09:23:01 UTC
vim-8.0.134-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-be5fa630c5

Comment 41 Gilboa Davara 2016-12-29 16:24:31 UTC
I can confirm 8.0.134.2 solves the problem on multiple machines.

Thanks.

Comment 42 Greta Watson 2016-12-29 16:37:06 UTC
vim-enhanced-2:8.0.134-2.fc24.x86_64 solved the problem for Fedora 24.

Thank-you.

Comment 43 Fedora Update System 2017-01-03 10:49:42 UTC
vim-8.0.142-1.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2017-562277cfd8

Comment 44 Fedora Update System 2017-01-03 22:21:26 UTC
vim-8.0.142-1.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-73038b8d65

Comment 45 Fedora Update System 2017-01-03 23:50:50 UTC
vim-8.0.142-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-562277cfd8

Comment 46 Fedora Update System 2017-01-05 20:22:12 UTC
vim-8.0.142-1.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 47 Fedora Update System 2017-01-06 04:04:20 UTC
vim-8.0.142-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 48 Zdenek Dohnal 2017-02-28 14:27:28 UTC
*** Bug 1382426 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.