Disable vim automatic visual mode using mouse

Last updated on Thu, 2010-10-14 20:33. Originally submitted by fabio on 2007-07-12 11:41.

I usually use Vim for command line text file editing.

Some days ago, probably due to a change in /etc/vimrc after a system update, the behavior of the mouse changed.

Selecting some text with the mouse automatically enter visual mode. I rarely use the visual feature and when I use it I prefer using the v keyboard command.

I found this new setting pretty annoying. So I decided to disable it.

If you also want do the same you can either:

  • issue the command :set mouse-=a
  • insert the directive set mouse-=a into your ~/.vimrc file
Posted in:

Copy text out of vim with set mouse=a enabled

Submitted by Anonymous (not verified) on Thu, 2012-12-06 07:21.

just say no! like the first post

Submitted by Shariar Kazi (not verified) on Sat, 2012-06-16 21:34.

add a " to the set mount directive:

Simple solution:

Orig:
set mouse=a
New (add "):
"set mouse=a

OR one Liner with perl:

perl -pi -e 's/set mouse=a/"set mouse=a/g' ~/.vimrc

vi(m) and mice ... just say no.

Submitted by Anonymous (not verified) on Mon, 2012-01-09 04:29.

just commented the offending section from /usr/local/share/vim/vimrc:
. . .
. . .
" In many terminal emulators the mouse works just fine, thus enable it.
" NO .... just no. Learn to use vi commands instead of this.
"if has('mouse')
" set mouse=a
"endif

rather than add:
set mouse-=a

Seems default behaviour is visual off and default vimrc was on. tada!.

Hope it helps.

Another aonnoying feature

Submitted by Anonymous (not verified) on Tue, 2010-11-23 00:39.

Recently the new version of vim when you make some visual-mode selection, put the "visualized" into the mouse buffer.
May be you know how to disable this feature, can you help me?

TIA

nope..

Submitted by fabio on Tue, 2010-11-23 00:46.

I'm sorry, never experienced that.. maybe you should ask directly to vim developers?

Good luck!

Toggle mouse on and off

Submitted by Cong (not verified) on Sat, 2010-10-02 20:32.

You can add this code into vimrc to toggle mouse on and off for (F12) Function key.

nnoremap :call ToggleMouse()
function! ToggleMouse()
if &mouse == 'a'
set mouse=
echo "Mouse usage disabled"
else
set mouse=a
echo "Mouse usage enabled"
endif
endfunction

This doesn't seem to work for

Submitted by fabio on Sat, 2010-10-02 23:52.

This doesn't seem to work for me.. Would you please check?

Slightly wrong

Submitted by Anonymous (not verified) on Thu, 2011-02-17 16:01.

Here's a version that uses F1 and turns off line numbering:

"Enable and disable mouse use
noremap :call ToggleMouse()
function! ToggleMouse()
if &mouse == 'a'
set mouse=
set nonumber
echo "Mouse usage disabled"
else
set mouse=a
set number
echo "Mouse usage enabled"
endif
endfunction

should have previewed, tags are being removed

Submitted by Anonymous (not verified) on Thu, 2011-02-17 16:06.

"Enable and disable mouse use
noremap <f1> :call ToggleMouse() <CR>
function! ToggleMouse()
if &mouse == 'a'
set mouse=
set nonumber
echo "Mouse usage disabled"
else
set mouse=a
set number
echo "Mouse usage enabled"
endif
endfunction

This feature makes actually

Submitted by Spliffster (not verified) on Mon, 2010-08-09 22:11.

This feature makes actually sense if one uses vim for more than basic editing. I am using vim for programming and have therefore line-numbers and color coding enabled always (set number, syntax on). When using the xterm for selecting text, line numbers are also selected which is very annoying.

Thanks for the hint on how i can set vim into visual mode by selecting with the mouse. in visual mode, the selection doesn't include the line numbers.

This combination makes actually sense:

set number
set mouse=a

Cheers,
-S

Thanks for your contribution.

Submitted by fabio on Tue, 2010-08-10 00:05.

Thanks for your contribution. With line numbers enabled the automatic visual mode using mouse actually makes sense.

Very thanks

Submitted by Valtoni Boaventura (not verified) on Mon, 2009-11-30 19:43.

It's very wonderful.
I don't see this answer in vim docs. Thanks again!

Thanks! I have no idea why

Submitted by James (not verified) on Mon, 2009-11-23 17:40.

Thanks! I have no idea why anybody would want a mouse in vim. That's a stupid feature. If you're using the mouse, you probably want to copy something OUT of the terminal, like text into a browser.
Anyway, thanks.

thanks a million

Submitted by ben (not verified) on Fri, 2009-11-20 14:28.

I wonder what happened to my putty software. I normally use the mouse right click to copy text into vi within putty. I stopped working oneday when there was a system update.

Now things back to normal. Visual mode is a bit confusing and I never used it anyway.

gnome-terminal

Submitted by R. Henze (not verified) on Thu, 2009-10-22 11:37.

Thank you very much! This was really annoying.
I assumed that this is a case of gnome-terminal.
So it took a while till I found your blog.
Best regards
R. Henze

Vim is not compiled with this enabled, except for gvim

Submitted by Anonymous (not verified) on Thu, 2009-10-15 21:03.

If you're seeing this effect in Putty, that means your sysadmin put it into the global vimrc file. If you build vim from source on your own machine, which doesn't already have a global vimrc file, you shouldn't this effect when you login to SSH using putty.

simple alternative solution

Submitted by Paweł (not verified) on Wed, 2009-10-07 12:32.

There's no need to disable this feature. Just hold shift while selecting text.

That doesn't help if you are trying to paste into Vim

Submitted by Paul Sture (not verified) on Wed, 2012-02-22 19:14.

Well, you can paste into Vim with the mouse enabled, but unless you are careful you'll lose your current cursor position and do the paste in the wrong place.

BRILLIANT!

Submitted by Anonymous (not verified) on Thu, 2010-10-14 20:23.

BRILLIANT!

thank you

Submitted by slacki (not verified) on Tue, 2009-08-11 15:35.

hi,
thank you for this information,
this fix my problems and i can now working
with (g)vi(m).

Reply

Submitted by Anonymous (not verified) on Sat, 2009-07-25 21:24.

It happened when I tried to write a code to add an action and enabled my module for the 1st time

I cannot see any connection between this and my code I actually just contained empty functions and hooks

This is not the 1st time I got this, last time I recovered from my nightly backup and lost the accesslog, watchdog and some cache I am not backing up nightly

I think this is a critical issue, I'll do my best to investigate it anyway your tip saved me! 10x!

Florida Permit Test

That is anoying

Submitted by JO (not verified) on Sat, 2009-05-23 18:47.

I hardly came across something more annoying as "visual" edit mode in VIM. I'm using putty a lot and the left mouse button is to paste text, not to enter "visual" mode, thank you very much.

If I want a "visual" editor vi, or vim, is the last thing I think about.

adding set mouse-=a to a file called ~/vimrc didn't change a thing. vim insisted on "visual" mode.

Please give me back vi

The file is called ~/.vimrc

Submitted by fabio on Sun, 2009-05-24 08:57.

The file is called ~/.vimrc - Note the dot: without it, it won't work.

THAT drives me insane!!! I

Submitted by Anonymous (not verified) on Wed, 2009-03-25 20:16.

THAT drives me insane!!! I hate to say this but that one that decided to do this as default setting should ___ right NOW!!!!

Thanks A LOT for this hint!

EDIT: removed offensive words

you shouldn't say that to

Submitted by fabio on Wed, 2009-03-25 20:51.

you shouldn't say that to anyone.

Thankyou thankyou ...the

Submitted by Anonymous (not verified) on Tue, 2009-03-24 12:18.

Thankyou thankyou ...the mouse feature was annoying me .... now i am happy

thank you, thank you thank

Submitted by marsh (not verified) on Thu, 2009-03-12 00:51.

thank you, thank you thank you ;)

this was annoying the crap out of me...

Thanks so much!

Submitted by Anonymous (not verified) on Wed, 2009-02-25 06:04.

I had resorted to head|tail file everytime I had to copy it over because of this annoying auto visual feature. Thanks for this setting and note!

hey, thanks for that. I

Submitted by icebird (not verified) on Fri, 2009-02-20 10:32.

hey, thanks for that. I wonder what they were thinking.

Thanks for the fix!

Submitted by Jason (not verified) on Fri, 2009-02-13 04:10.

This has been killing me too. Now if I can only find an app that will let me cat files to the clipboard. BTW it looks like you're using Drupal for you website. Drupal rocks!

I'm glad i wasn't the only

Submitted by Anonymous (not verified) on Tue, 2009-01-06 17:14.

I'm glad i wasn't the only one going nuts.. thanks!

Oh my god THANKS

Submitted by Dam (not verified) on Thu, 2008-12-11 10:40.

Was driving me crazy, I knew something was up with my .vimrc because renaming it would restore the old behaviour, but jeez...

This was a horribad feature, leave my mouse alone >.<

thankyou very much!

Submitted by lll9p (not verified) on Wed, 2008-11-05 17:39.

it fixs haha

THANKS !!!

Submitted by Anonymous (not verified) on Mon, 2008-07-21 15:51.

Now that I control my mouse, i can work again.

thank you

Submitted by Anonymous (not verified) on Tue, 2008-07-15 18:25.

Aaargh. Another source of frustration conquered. Thank you. My wheel continues to work, too. Yay!

yes, that visual mouse was

Submitted by iv (not verified) on Tue, 2008-06-03 15:43.

yes, that visual mouse was highly irritating. thanks for the post.

good point with old dogs :)

thanks, tip was really

Submitted by sundeep (not verified) on Fri, 2008-03-28 09:10.

thanks, tip was really helpful.
i was trying to copy the name of function from the vim editor into gbd window. Was unsuccessful till now :)

Oh dear, THANK YOU!

Submitted by jiki (not verified) on Tue, 2007-11-06 21:38.

It was driving me crazy too, I thought at first that there was sth wrong with my laptop.

Looks like vim people can't teach old dogs new tricks:)

cheers

I too had this problem.

Submitted by Jobias (not verified) on Fri, 2007-09-14 21:09.

I too had this problem. However, one thing I now miss about vim is that the mouse wheel no longer works. It seems as if setting mouse=a instead of mouse-=a, while producing the annoying auto-visual mode behavior, also enables the mouse wheel. Ah well, the trade-offs are worth it.

thank you for posting this

Submitted by Anonymous (not verified) on Fri, 2007-08-03 15:14.

thank you for posting this fix. This problem has been driving me nuts