tags:

views:

194

answers:

2

I'm using Vim 6.3.81 on a x-term through putty. I wanted to map mouse events (like wheel-button click , double click) to specific events using my .vimrc . I've looked at the vim wiki and based on it, defined the following map in my .vimrc:

:nnoremap <2-LeftMouse> :set invnumber<CR>

However , it is not working - double-click is not toggling the line numbers as intended . Do I have to change my X settings to get vim to accept mouse events ?

Thanks...

A: 

As far as I know you cannot map mouse events through the putty window. The only thing you can do with the mouse is copy and paste.

It would probably be best if you tried to learn to live without the mouse as this is the "power editor philosophy". You're more efficient if your hands stay on the keyboard.

Pierre-Antoine LaFayette
Well , that makes two of us - I also thought it can't be mapped. But see Andrew's answer below - if I first set vim to accept mouse events using `set mouse=a` , then it works fine !!
shan23
+2  A: 

Have you issued a :set mouse=a or similar?

Vim can accept mouse input through the terminal, but it needs to be explicitly enabled. Both PuTTY and xTerm support it.

:help mouse for more details.

Andrew Aylett
Thanks...works now like a charm. But now I have a bigger problem - enabling mouse events dissable text selection via mouse, which is not what I want. You have answered a similar question of mine regarding text selection in vim through putty , so I guess you know what I wanted...Anyway , this is the best answer possible I guess - i'll just have to decide between enabling mouse events and disabling text selection!!
shan23
Hold down shift while selecting using the mouse and PuTTY will pick up the mouse events itself, rather than handing them to the application.
Andrew Aylett
Great answer to a tricky situation !! So the solution is just to hold down the shift key while selecting text using mouse , after ensuring mouse is activated in vim. Thanks !
shan23