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?
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=
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
– Kevin
Jan 13 '17 at 18:44
'mouse'
isn't a boolean option.
– Luc Hermitte
Jan 13 '17 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