How do I get the terminal within GVim to react to mouse scrolls? - vim

I'm on a Hardy Heron Ubuntu build, BTW.

Try:
:set mouse=a
":help mouse" says
Enable the use of the mouse. Only works for certain terminals
(xterm, MS-DOS, Win32 |win32-mouse|, qnx pterm, and Linux console
with gpm). For using the mouse in the GUI, see |gui-mouse|.
The mouse can be enabled for different modes:
n Normal mode
v Visual mode
i Insert mode
c Command-line mode
h all previous modes when editing a help file
a all previous modes
r for |hit-enter| and |more-prompt| prompt
A auto-select in Visual mode
Normally you would enable the mouse in all four modes with: >
:set mouse=a
When the mouse is not enabled, the GUI will still use the mouse for
modeless selection. This doesn't move the text cursor.

Hate to give this answer, because it isn't very helpful, but it works fine for me (scroll wheel in gvim on ubuntu hardy).
But maybe I can suggest some things that help debug the issue:
Confirm you are running "gvim" and trying to scroll the new window that comes up (i.e. you are not running vim in an xterm and trying to scroll that with the mouse)
Confirm the scroll wheel works in other apps. Use "xev" to make sure the X server is seeing the scroll events if you're unsure.
Hope that helps.

Related

Vim - Colorscheme leaves trailing black (whitespace) in random places

Vim & NeoVim both leave patches of simply black text scattered in random locations across the viewport. This is most common when scrolling or jumping between locations. This affect has happened on multiple different colorschemes so I suspect its more a problem with vim or my shell, than with the scheme. Generally when I load a file these patches don't exist, but they appear pretty quickly after starting vim. Reloading my configuration file or changing the scheme definitely makes them appear. Restarting the shell or quitting and restarting vim doesn't have any affect.
I'm running windows build 17763.92 on windows 10 Education & vim/neovim on Ubuntu (version 18.04 Bionic) bash for windows under the WSL.
Could anyone enlighten me as to why this is happening?
Heres my vim version info.
Heres my vimrc File & A Screenshot of The Described Affect.
This is usually caused by a wrong terminal setting in $TERM. The commands that Vim sends to the terminal to clear it then don't properly set the background color, and only text written on top has the correct background.
If you don't find a fix for that, you can work around the problem by clearing the background color of the Normal highlight group:
:hi Normal ctermbg=NONE
This happened to me as well, I would get black highlighting when opening a new line using o or O, and it would also appear when paging down (ctrl D) then scrolling up (k).
I was using vim (.vimrc - colorscheme desert with syntax on) on windows ubuntu subsystem WSL.
I was able to make it go away by updating my Windows 10 version 1909, to Windows 10 version 2004.
My problem was similar to this post: https://vi.stackexchange.com/questions/21437/vim-is-highlights-everything-after-eol-in-yellow-upon-scrolling
and, someone had also mentioned it being related to the terminal type xterm-256color here (their recommendation was to upgrade Windows version, it worked for me): https://superuser.com/questions/1526515/vim-highlighting-newlines-in-a-file-how-to-disable

Mouse scrolling in vim scrolls terminal window

I am just getting started using Vim and came across :set mouse=a which I've found really useful for navigating a file, however for some reason when I try and scroll now it scrolls the whole terminal window and not just the vim window.
Then I scroll up and can see the terminal outside Vim
Any ideas on how to fix this? I've tried resetting mouse= and exiting and re entering vim.
The problem was that I had accidentally disabled Allow Mouse Reporting in error.
Checking Menu > View > Allow Mouse Reporting or Cmd + R has fixed it!
I think the cheap answer to your question is that you should be navigating through files in vim using motion commands, Ctrl + d, etc. It might seem slow at first, but it really becomes more natural down the line.
That said, if you are on Mac and using Terminal, you might need to hold the Fn to temporarily disable mouse support. (Check this out for reference: OS X Terminal Mouse Support
Also, you can always try MacVim, which supports mouse scrolling out of the box.
If neither of those solutions work for you, some more information would be helpful for troubleshooting, e.g., your operating system, recent changes to your vimrc, etc.

Disabling mouse support on ideavim

Is there a way to disable mouse support in file edition on ideavim? It is really annoying that it enters into visual mode each time I click.
It isn't possible to have the same behavior as vim without mouse in terminal, but can I have it on pycharm's ideavim?
I also hate when the editor suddently goes into visual mode when I accidentally drag with the mouse. I ended up modifying the ideavim source and compiled my own version. I got the idea from another answer https://stackoverflow.com/a/24256022/598781
I just return immediately in the EditorMouseHandler.mouseDragged method. i.e. changed line 1772 in the file ideavim/src/com/maddyhome/idea/vim/group/MotionGroup.java to:
if (true || !VimPlugin.isEnabled()) return;
This change could have some consequences, but I don't use mouse select anyway.
It's not possible to disable mouse support in Vim emulation. Note however that IdeaVim switches to Visual selection mode only when you're selecting text with the mouse. Simple clicks shouldn't make IdeaVim enter visual selection mode.
You should try :set selectmode=mouse,ideaselection. It is a workaround but that worked for me.
https://github.com/JetBrains/ideavim/blob/master/doc/set-commands.md

Focus follow mouse in vim

I am aware that the mousefocus option is only supposed to work in gVim. But I was wondering, if it's possible to have the console Vim switch to different windows in response to mouse clicks, would it be not possible to easily add following mouse movement to it, too?
I'm an xmonad user, I love the focus following the pointer feature, I do a lot of pdf viewing and browsing while writing in Vim, and I'd be so much happier if I didn't have to keep mentally switching back and forth between two different types of focus changing.
If that's completely not possible, I guess opening new Vim windows (as with :split) in new instances of the terminal is no easier to do?
It would not be at all simple to add this. Using the mouse within the terminal works by vim sending control codes to the terminal requesting that mouse actions be sent as part of the input stream. Terminals only report clicks not changes in the pointer position, so vim has no way of knowing where the mouse is.
With major changes it would likely be possible for a vim with X support to get pointer activity directly from the X server, but that would likely be reported by pixel rather than by character so further work would need to be done before it could determine which vim window is currently under the pointer.
set mouse=a
should do the trick but it will probably depend on your terminal emulator. See :help 'mouse'.
This works for Windows 7/Cygwin 32bit mintty/vim 7.3: (I DO NOT use gvim!)
Having installed this: http://ehiti.de/katmouse/, I can scroll the window under my cursor without having to have clicked to select a window, click-selecting of single vim-windows works, too. It does not pull the vim window to the foreground, if another window overlaps it, if that is what you desire. Still it can be scrolled without click-selecting it first.
So:
Check if there exists a software paket for your distribution, that implements your desired mouse behavior on the OS level. When this works for my self-compiled vim in cygwin, it might very well work with console vim on linux, too.
This post here serves as evidence, that it is possible at all, that is the reason this was not made a comment. When I am on linux again I will investigate this further and update this post, but that might take a while.
On set mouse=a: The vim help states you a need a terminal capable of handling mouse inputs, further information can be found here. :help ttymouse might also be helpful, i.e. if you have a xterm-compliant console, but :help term is set to something else.
UPDATE: (Freshly installed Fedora 19 with packages, no self-compiled stuff.)
Fedora 19 + se mouse=a = scrolling in single console vim window with several buffers opened next to each other independently works, too. Window manager used is LXDE.

Show input keystrokes in Vim

When I installed Vim on Windows, it (specifically gVim) used to show to show me the keystrokes I am currently entering in the bottom right corner of the screen.
But now I'm working with gVim on Linux, and it doesn't show me.
Is there a setting (:set) I need to turn on to do this ?
The option you're looking for is showcmd.

Resources