I've added this script to my vimrc file
command! EnableMouse :call EnableMouseFunction() function! EnableMouseFunction() let command = ":set mouse=a" exe command endfunction
So, ... what is the method to unset mouse in vim?
You don't need anything that complex
set mouse=a " and set mouse=
You can even define your command to be
:command! ToggleMouse exe 'set mouse='.(empty(&mouse)?'a':'') " Here I use `:exe` because I didn't want to use `:if` in a command definition which would look like: :command! ToggleMouse if empty(&mouse) | set mouse=a | else | set mouse= | endif
The use of the mouse is controlled (as you find out) with the
mouse setting. It is activated only if
mouse is equal to "something". This something determines when is the mouse used.
To disable the mouse you can simply:
Also in your function, you can call the
set command directly:
function! EnableMouseFunction() set mouse=a endfunction