lrhorer
Posts: 67
Joined: Sun Feb 22, 2015 6:35 pm

vim is weird on RPi

Mon Apr 08, 2019 10:19 am

This is driving me crazy. OK, I use vim - a lot. I like its features, and it is available on all my Linux systems -also a lot. The version of vim on the RPi systems (or maybe it is a Jessie thing: at this point only my Raspberry Pi hosts are running Jessie) is aggravating , though. Among my top complaints:

1. The cursor moves with the mouse pointer. I don't like this, at all. One of the really great things about vim is its ability to highlight one section of the screen while leaving the cursor elsewhere. This new behavior is like Windows, and it really sucks.

2. Related to #1, after highlighting any text, the app automatically switches to VISUAL mode, wherein one can no longer type in text. Rather than automatically loading the highlighted text into the keyboard, one must hit the (Y)ank key. At this point, the text is loaded into the vim clipboard not the Linux clipboard!), the mode drops back to its previous value (actually, this bit is sort of cool), and removes the highlighting (seriously?).

3. Vim no longer employs, or to some extent it seems even interacts with the OS clipboard. Are you kidding me?
What's more, who ever had an idea it was preferable in any way to the previous behavior. Cut-and-paste between vim and the parent shell, between one instance of vim and another, or between some other application and vim used to be quick, simple, and easy. Now it is terrible. To paste from some other window, instead of simply hitting the middle mouse button, one must hit <Ctrl><Shift>v, or click on [file][paste]. I don't mind having the keyboard and drop-down versions of the Paste function - I think it is a very good idea, but pasting from the mouse should be identical to pasting from the keyboard and the drop-down. More importantly, while pasting is now a pain, I haven't been able to figure out any way to copy text from vim to the system keyboard. That is completely unacceptable. (Can anyone tell me how to accomplish this, by the way?) If I want to copy to the system clipboard, I have to save my changes to the file being edited, hit <Ctrl>z to drop back to the parent shell, type cat, more, or less, and highlight the text with the mouse. There is absolutely no reason why vim should not continue to work in precisely the same way BASH and essentially every other application does under Linux. Trying to make a Linux app more like Windows apps is not a welcome idea. In fact, it is just stupid. I use Linux so I don't have to contend with moronic Windows features.

OK, enough ranting. I realize first of all this may be either a Debian / Raspbian version issue or a vim developer issue, in which case I may need to take my complaints to the vim developers or the distro managers, rather than this forum. I am hoping, however, that someone here may be able to tell me there is a way to get vim 8.0 under Raspbian Jessie to behave like its previous versions in terms of the mouse actions. I didn't spot anything in the man page. If not, can someone at least tell me how to get text out of an instance of vim into an external application?

[moderator removed some swear words]

User avatar
DougieLawson
Posts: 38777
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: vim is weird on RPi

Mon Apr 08, 2019 10:32 am

sudo apt install vim-full will get it working normally.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

jjhaywor
Posts: 2
Joined: Tue Apr 09, 2019 8:17 pm

Re: vim is weird on RPi

Tue Apr 09, 2019 8:19 pm

Or you could compile it from the source which I've found has worked best, lets you specify the pi's specific python configs etc. https://github.com/Valloric/YouComplete ... rom-source

dennyfmn
Posts: 38
Joined: Thu Aug 16, 2012 1:36 pm
Location: Minnesota/California USA

Re: vim is weird on RPi

Wed May 27, 2020 9:21 pm

vim-full does not exist on Buster. I have vim installed. vim-tiny is also on the system, but the vim alternative points to /usr/bin/vim-basic.

vim --version reports:
VIM - Vi IMproved 8.1
Huge version without GUI.

Can someone please post vimrc settings to restore the previous defaults? I have the same issues as the original poster.

I have spent a couple of hours researching and trying various settings. No joy. Using the shift key with mouse drag/copy and paste helps, but that's not the way it used to work. I have many different linux systems with vim on them and I'd like them all to act the same.

User avatar
PeterO
Posts: 5820
Joined: Sun Jul 22, 2012 4:14 pm

Re: vim is weird on RPi

Wed May 27, 2020 9:32 pm

More up to date thread from a few days ago. You did search for vim didn't you ?

viewtopic.php?f=66&t=274704&p=1665193&h ... m#p1665193

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
dickon
Posts: 1411
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: vim is weird on RPi

Wed May 27, 2020 9:33 pm

Necroed thread.

:set mouse=

should solve your problem. If I ever find the idiot who decided mouse support should be a thing...

User avatar
DougieLawson
Posts: 38777
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: vim is weird on RPi

Wed May 27, 2020 10:36 pm

dickon wrote:
Wed May 27, 2020 9:33 pm
Necroed thread.

:set mouse=

should solve your problem. If I ever find the idiot who decided mouse support should be a thing...
Is there a way to set that permanently in .vimrc or /etc/vimrc? Because that bugs me every time I want to paste code into a vim session.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Heater
Posts: 15778
Joined: Tue Jul 17, 2012 3:02 pm

Re: vim is weird on RPi

Thu May 28, 2020 12:39 am

Dougie,

Here is a strange thing that may or may not help...

To stop the mouse clicks moving the cursor and get pasting working nicely I just create an empty file ~/.vimrc. Yep, that's it, just an empty .vimrc.

But I should be specific, this is vim running under Debian running under the Linux Subsystem for Windows in Windows 10. Out of the box the cursor follows the mouse clicks and pasting text from elsewhere into vim requires clicking on the bar at the top of the terminal, selecting "edit" from a drop down menu then selecting "paste" from a sub-menu. Infuriating.

With that empty .vimrc the cursor stays where it should and a right mouse click pastes the text.

Despite using vim all the time I almost never mess with it's configuration, except to enable syntax high lighting. Fixing this behavior had me beat til I read this little trick some place.

Sorry I don't have a Pi to hand to test it on just now.
Memory in C++ is a leaky abstraction .

dennyfmn
Posts: 38
Joined: Thu Aug 16, 2012 1:36 pm
Location: Minnesota/California USA

Re: vim is weird on RPi

Thu May 28, 2020 12:46 pm

Hmmm...

If I type
:set mouse=
in a vim session it works correctly

If I put
set mouse=
in ~/.vimrc, it works correctly

If I put
set mouse=
at the end of /etc/vim/vimrc
it does not work correctly, it goes into VISUAL mode

I would like it to work correctly for all users by changing /etc/vim/vimrc. Can someone explain this?

A little more information:
tail /etc/vim/vimrc

"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
set mouse=

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif

I checked and /etc/vim/vimrc.local does not exist.

With /etc/vim/vimrc as above, in a vim session:
:set mouse?
shows
mouse=a (not using the value in /etc/vim/vimrc)

with ~/.vimrc active, in a vim session
:set mouse?
shows
mouse= (using the value in ~/.vimrc)

What is going on here?

Heater
Posts: 15778
Joined: Tue Jul 17, 2012 3:02 pm

Re: vim is weird on RPi

Thu May 28, 2020 5:01 pm

Nobody knows.

I had another google around since my last post.

Apparently one can set "mouse=r" and "mouse=v" in /etc/vim/vimrc.

None of them do what I want in my situation.

But having a totally empty ~/.vimrc file does the job nicely. Cursor does not follow mouse and right click pastes text without having to jump through menu hoops.

Still no idea why.
Memory in C++ is a leaky abstraction .

User avatar
DougieLawson
Posts: 38777
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: vim is weird on RPi

Thu May 28, 2020 5:04 pm

Heater wrote:
Thu May 28, 2020 5:01 pm
But having a totally empty ~/.vimrc file does the job nicely. Cursor does not follow mouse and right click pastes text without having to jump through menu hoops.
That's called a "bug that's become a feature" or "broken as coded".
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

ejolson
Posts: 5109
Joined: Tue Mar 18, 2014 11:47 am

Re: vim is weird on RPi

Thu May 28, 2020 5:13 pm

DougieLawson wrote:
Thu May 28, 2020 5:04 pm
Heater wrote:
Thu May 28, 2020 5:01 pm
But having a totally empty ~/.vimrc file does the job nicely. Cursor does not follow mouse and right click pastes text without having to jump through menu hoops.
That's called a "bug that's become a feature" or "broken as coded".
I think it was an intentional but bad design decision made by the developers.

Here is an earlier discussion.

viewtopic.php?t=238001&start=375#p1466316

HiassofT
Posts: 282
Joined: Fri Jun 30, 2017 10:07 pm
Location: Salzburg, Austria
Contact: Website

Re: vim is weird on RPi

Thu May 28, 2020 9:01 pm

I'm not a fan of default mouse support in vim either, but the hints on why "set mouse=" in /etc/vim/vimrc (or .local) doesn't work are in the /etc/vim/vimrc file:
" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
" This happens after /etc/vim/vimrc(.local) are loaded, so it will override
" any settings in these files.
" If you don't want that to happen, uncomment the below line to prevent
" defaults.vim from being loaded.
" let g:skip_defaults_vim = 1
/usr/share/vim/vim81/defaults.vim contains this block:

Code: Select all

" 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
Which gets executed after /etc/vim/vimrc (.local) is read - so any mouse= setting in there will have no effect.

Removing the comment on the "let g:skip_defaults_vim = 1" line will prevent defaults.vim from being loaded - and thus mouse support being off.

If you still want the settings from defaults.vim, then source it manually at the end of vimrc and later override the mouse setting.

so long,

Hias

User avatar
DougieLawson
Posts: 38777
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: vim is weird on RPi

Thu May 28, 2020 9:24 pm

HiassofT wrote:
Thu May 28, 2020 9:01 pm

/usr/share/vim/vim81/defaults.vim contains this block:

Code: Select all

" 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
Thank you. That block of code is now a comment on my systems.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

ejolson
Posts: 5109
Joined: Tue Mar 18, 2014 11:47 am

Re: vim is weird on RPi

Thu May 28, 2020 9:29 pm

HiassofT wrote:
Thu May 28, 2020 9:01 pm
/usr/share/vim/vim81/defaults.vim contains this block:

Code: Select all

" 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
There's another puzzle, then, why local preferences don't take priority.

After commenting it out, such as

Code: Select all

" In many terminal emulators the mouse works just fine.  By enabling
" this option, however, you can break it.
"if has('mouse')
"  set mouse=a
"endif
could someone issue a pull request?

These continuing difficulties have taken all the Joy out of vi for me.

Heater
Posts: 15778
Joined: Tue Jul 17, 2012 3:02 pm

Re: vim is weird on RPi

Thu May 28, 2020 11:51 pm

ejolson wrote:
Thu May 28, 2020 9:29 pm
These continuing difficulties have taken all the Joy out of vi for me.
I see what you did there.

Exactly, what I want to know is how to do that " later override the mouse setting." part that HiassofT mentioned.
Memory in C++ is a leaky abstraction .

GlowInTheDark
Posts: 561
Joined: Sat Nov 09, 2019 12:14 pm

Re: vim is weird on RPi

Fri May 29, 2020 2:10 am

My sense of this whole thread is that it is about using the text version of VIM and having the mouse be active. I rarely use the text version of VIM (on either of the major platforms), so I can't comment further, except to say that at one point, I was getting annoyed at the mouse-handling in Windows GVIM, so I turned the mouse off there (for some reason, that I no longer remember).

But, on the subject of whether or not programs running under terminal emulators under X should use the mouse, I will say that I generally agree (that they should not), but there is one nice exception. tmux does nice things with the mouse. You should check it out.
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Heater
Posts: 15778
Joined: Tue Jul 17, 2012 3:02 pm

Re: vim is weird on RPi

Fri May 29, 2020 2:49 am

I don't much care if one likes to have the cursor follow mouse clicks or not. In vim or anywhere else.

I just want to know how to get the setting to work in Vim. I just happen to want the cursor to not follow the mouse and for cut and paste to work sensibly. I have tried every which way to do it but the only thing that works is having an empty .vimrc file. Which seems kind of daft to me.

In general though it drives me nuts that simple things like cut and paste work differently on every damn machine. Do you need Control-V or Shift-Control-V, or a right mouse click, or a middle button click or in the case of my Vim in LSW on Win 10 open a menu select "edit" then select "paste" or...
Memory in C++ is a leaky abstraction .

ejolson
Posts: 5109
Joined: Tue Mar 18, 2014 11:47 am

Re: vim is weird on RPi

Fri May 29, 2020 4:02 am

Heater wrote:
Fri May 29, 2020 2:49 am
In general though it drives me nuts that simple things like cut and paste work differently on every damn machine. Do you need Control-V or Shift-Control-V, or a right mouse click, or a middle button click or in the case of my Vim in LSW on Win 10 open a menu select "edit" then select "paste" or...
If ^C means copy, then delete could mean ^C as in the original Unix terminal drivers. After that ^H could be used for delete and for help one could call 911.

I think the inconsistencies happened because Linux got popular and people accustomed to Windows wrote programs with cut, copy and paste that work like Microsoft while at the same time people accustomed to the Macintosh wrote programs that work like Apple.

The solution is quite simple, wire three buttons to the GPIO: one blue, one red and one white. Arrange them like the Zenith Data Systems clone of the VT52
.
Z19_keyboard.jpg
Z19_keyboard.jpg (58.79 KiB) Viewed 675 times
.
or alternatively like the original.

Since blue should obviously be cut, red copy and white paste, then map those buttons to the keysyms XK_Cut, XK_Copy and respectively XK_Paste. Note you may need to edit keysymdef.h and recompile X to make these keysyms available.

After that, the rest is a simple matter of deleting the programs that are not worth patching to recognize the new keysyms.

User avatar
dickon
Posts: 1411
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: vim is weird on RPi

Fri May 29, 2020 7:30 am

There's also the X resource XTerm.allowMouseOps which may or may not help you. I'm getting inconsistent results.

User avatar
DougieLawson
Posts: 38777
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: vim is weird on RPi

Fri May 29, 2020 8:29 am

dickon wrote:
Fri May 29, 2020 7:30 am
There's also the X resource XTerm.allowMouseOps which may or may not help you. I'm getting inconsistent results.
That's irrelevant if you're running in a cli or ssh session.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

User avatar
dickon
Posts: 1411
Joined: Sun Dec 09, 2012 3:54 pm
Location: Home, just outside Reading

Re: vim is weird on RPi

Fri May 29, 2020 8:39 am

Well, if you're sshing from an xterm -- which I do rather a lot of -- it seems rather pertinent. If the xterm doesn't pass on the mouse ops via whatever escape sequences it uses, then the vim on the remote Pi shouldn't be seeing them. Or so I'd hoped.

Heater
Posts: 15778
Joined: Tue Jul 17, 2012 3:02 pm

Re: vim is weird on RPi

Fri May 29, 2020 11:12 am

I'm quite happy with the difference between a Unix Control-C and a Windows Control-C. Been living with that pain long enough to get used to it.

And there is always scope for confusion between the program you are talking to, which tries to interpret it's input as best it can, and the terminal you are using and the OS that is running on and the connection between the two. The result is chaos where simple things like cut and paste don't work the same way in any two situations. Sometimes one can spend half a day figuring out how to set everything up "just so". Or one just has to learn to change habits when switching from machine to machine. Grrr....

But, as I described above, I can't easily copy and paste in and out of Vim without that empty .vimrc file. Which is daft. Still looking for a "proper" way to do it.
Memory in C++ is a leaky abstraction .

HiassofT
Posts: 282
Joined: Fri Jun 30, 2017 10:07 pm
Location: Salzburg, Austria
Contact: Website

Re: vim is weird on RPi

Fri May 29, 2020 11:40 am

DougieLawson wrote:
Thu May 28, 2020 9:24 pm
HiassofT wrote:
Thu May 28, 2020 9:01 pm

/usr/share/vim/vim81/defaults.vim contains this block:

Code: Select all

" 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
Thank you. That block of code is now a comment on my systems.
I strongly advise against editing /usr/share/vim/vim81/defaults.vim, that file will be automatically replaced whenever vim is updated (via apt upgrade).

It's better to change /etc/vim/vimrc, then apt upgrade will detect the modifications and ask you what to do, or put the changes into /etc/vim/vimrc.local if you don't want to be bothered with questions on apt upgrade.

See also the comments and suggestions in the Debian bug report https://bugs.debian.org/cgi-bin/bugrepo ... bug=864074

so long,

Hias

User avatar
DougieLawson
Posts: 38777
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: vim is weird on RPi

Fri May 29, 2020 11:43 am

HiassofT wrote:
Fri May 29, 2020 11:40 am

I strongly advise against editing /usr/share/vim/vim81/defaults.vim, that file will be automatically replaced whenever vim is updated (via apt upgrade).
apt has stuff in place to notice that and ask you to resolve it. I'm happy with the way I've hacked it.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Advanced users”