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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou don't need anything that complex
set mouse=a
" and
set mouse=
are enough.
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
:set mouse!
will toggle. See :help :set-inv
'mouse'
isn't a boolean option.
Jan 13, 2017 at 18:56
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:
set mouse=
Also in your function, you can call the set
command directly:
function! EnableMouseFunction()
set mouse=a
endfunction