Vim disable mouse only in insert mode
Asked Answered
R

1

7

When I insert mode sometimes my cursor moved because my palm accidentally placed on trackpad. So, I want to make autocmd to disable mouse on insert mode and enable it in normal mode.

I write it like this:

  autocmd InsertEnter * set mouse=""
  autocmd InsertLeave * set mouse=a

It worked to disable the mouse. But, when I leave the insert mode, the mouse not activated.

How to make this work?

Edit: I just found out that InsertLeave not triggered when I'm using CTRL_C. Unfortunately, I always use CTRL_C to exit insert mode. Is there any workaround for this?

Edit 2: I found out UserGettingBored event too. But it seems this event is just a joke.

Renege answered 14/4, 2016 at 6:27 Comment(0)
R
5

You could use:

set mouse=n

to only enable mouse in normal mode

Renege answered 14/4, 2016 at 6:45 Comment(1)
I ended up using set mount=nv because sometimes I select text with the mouse, but otherwise this is a perfect answer. Thanks!Encephalograph

© 2022 - 2024 — McMap. All rights reserved.