How to make Vim having a little better mouse support

63 views
Skip to first unread message

Igor Lerinc

unread,
Nov 13, 2023, 9:35:11 AM11/13/23
to vim_use
Yes, I did all tips I could apply about enabling mouse support in `.vimrc`, but I just want to have mouse support like in every other GUI editor.



1. I just need it to be able scroll with mouse selection (when I select, and go UP, it wont scroll to up like in every GUI editor does) (it can go DOWN though) .

2. When I click two times, that it do usual thing GUI editors would do, to select that word, or even whole line on three clicks. (currently, just works, on selecting whole line on three clicks)

3. And could that cursor be as line always, and not in block when it's normal mode ? it would be nice, if there's some plugin, to change color of cursor, so I could know I'm in normal/insert mode.


Here is init.vim , I enabled those things but it's not enough as GUI editors do mouse support better.

I'm mainly using vim (neovim plugin) in VSCode, so that's why I need it more mouse friendly.  


P.S. this is actually neovim, but same would apply, it doesn't have support for mouse good enough

Gary Johnson

unread,
Nov 13, 2023, 5:06:15 PM11/13/23
to vim_use
On 2023-11-13, Igor Lerinc wrote:
> Yes, I did all tips I could apply about enabling mouse support in `.vimrc`, but
> I just want to have mouse support like in every other GUI editor.
>
>
>
> 1. I just need it to be able scroll with mouse selection (when I select, and go
> UP, it wont scroll to up like in every GUI editor does) (it can go DOWN though)
> .

vnoremap <ScrollWheelUp> k
vnoremap <ScrollWheelDown> j

> 2. When I click two times, that it do usual thing GUI editors would do, to
> select that word, or even whole line on three clicks. (currently, just works,
> on selecting whole line on three clicks)

This works as you want it to, right? Double- and triple- clicks
work that way for me.

> 3. And could that cursor be as line always, and not in block when it's normal
> mode ? it would be nice, if there's some plugin, to change color of cursor, so
> I could know I'm in normal/insert mode.

See

:help 'guicursor'

That covers both shape and color.

HTH,
Gary

Igor Lerinc

unread,
Nov 13, 2023, 5:50:57 PM11/13/23
to vim...@googlegroups.com
> This works as you want it to, right?  Double- and triple- clicks work that way for me.

Double click, should select word. Doesn't work.


> vnoremap <ScrollWheelUp> k
> vnoremap <ScrollWheelDown> j

this works, but is there way that it goes UP, like it does when going DOWN, that it automatically expands toward UP. I don't know if it's because of my xfce4 terminal, and terminal doesn't send some stuff ? Which terminal you use ? 





--
--
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 a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/fj_QrzAydfw/unsubscribe.
To unsubscribe from this group and all its topics, 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/20231113220511.GA4044%40phoenix.

Gary Johnson

unread,
Nov 13, 2023, 7:57:05 PM11/13/23
to vim...@googlegroups.com
On 2023-11-13, Igor Lerinc wrote:
> > This works as you want it to, right?  Double- and triple- clicks work that
> way for me.
>
> Double click, should select word. Doesn't work.

That's odd. I've tried gvim, vim in an xterm, vim in a GNOME
Terminal, and vim in an xfce4-terminal (version 0.8.9.1) and
double-clicking always selects one word. I started each one with
"-N -u NONE -i NONE" arguments to make sure I didn't include
anything from my vimrc or plugins.

> > vnoremap <ScrollWheelUp> k
> > vnoremap <ScrollWheelDown> j
>
> this works, but is there way that it goes UP, like it does when going DOWN,
> that it automatically expands toward UP. I don't know if it's because of my
> xfce4 terminal, and terminal doesn't send some stuff ? Which terminal you use ?

To make those two mappings move in the opposite direction, just swap
the j and k, like this:

vnoremap <ScrollWheelUp> j
vnoremap <ScrollWheelDown> k

I almost always use an xterm, although I tried the others above to
see if they would behave any differently. It turned out that
mapping the scroll wheel worked in all cases, but it worked
differently depending on the terminal and the window manager.

You can determine the escape sequence received by Vim in response to
using the scroll wheel by opening a new line, typing Ctrl-K, the
moving the scroll wheel once up or down. You should see the key
code, like this:

<ScrollWheelUp>

or

<ScrollWheelDown>

That's what I see when using xterm or GNOME Terminal in a GNOME 42
desktop on Ubuntu 22.04. However, on my Ubuntu 20.04 system running
the xfce4 desktop, xfce4-terminal shows

<2-ScrollWheelUp>

and

<2-ScrollWheelDown>

while xterm shows

<3-ScrollWheelUp>

and

<3-ScrollWheelDown>

Very odd. It's a simple matter to change the mapping to match those
key codes, but I don't understand why they're different. You don't
seem to see those, but I thought I should mention it in case you had
problems with those mappings.

Since you said that you wanted Vim to behave as other GUI editors
do, I assumed at the time that you were using gvim. The 'guicursor'
option works in the GUI but not in a terminal. To change the cursor
shape or color when using vim in a terminal, see:

:help termcap-cursor-shape

Regards,
Gary

Gary Johnson

unread,
Nov 14, 2023, 1:29:25 PM11/14/23
to vim...@googlegroups.com
On 2023-11-13, Gary Johnson wrote:
> On 2023-11-13, Igor Lerinc wrote:
> > > This works as you want it to, right?  Double- and triple- clicks work that
> > way for me.
> >
> > Double click, should select word. Doesn't work.
>
> That's odd. I've tried gvim, vim in an xterm, vim in a GNOME
> Terminal, and vim in an xfce4-terminal (version 0.8.9.1) and
> double-clicking always selects one word. I started each one with
> "-N -u NONE -i NONE" arguments to make sure I didn't include
> anything from my vimrc or plugins.

P.S.

You'll also have to

:set mouse=a

in those terminal vims to check whether double clicking works.
Otherwise, you'll just be seeing the behavior of the terminal, not
vim.

Regards,
Gary

Reply all
Reply to author
Forward
0 new messages