2

How can I configure vim to use the mouse to resize window splits but not reposition the cursor when I click elsewhere in the buffer ?

:set mouse=n enables window split resizing in Normal Mode but also moves the cursor when I left-click on some text. But with set mouse= neither work.

It seems the two behaviours are inextricably linked.

2

It seems the two behaviours are inextricably linked.

You seem to be right. I tried

:nnoremap <LeftMouse> <Nop>

But that suppresses both cursor positioning and window resizing.

I only managed to get close to the behavior you want by storing the current mouse position on the click, and restoring it on the click release. You'll still briefly see the cursor flickering, but at least it maintains its position:

:nnoremap <LeftMouse> m'<LeftMouse>
:nnoremap <LeftRelease> <LeftRelease>g``
| improve this answer | |
  • Interesting. I didn't know you could map mouse clicks like that. But I'm not sure if I can live with the cursor jumping arround like that. Also with that mapping and gvim, mouse selections go a bit weird. I think you've probably answered my question though. I think the upshot will be that I need to either learn to resize windows via the keyboard, or learn to live with the mouse. – Lqueryvg Apr 29 '14 at 15:07
  • Yeah, this probably requires some more tweaking, but I'd also suggest to memorize the keyboard <C-W>... commands to influence the window layout. I'm fine with a quick mouse selection when coming from elsewhere, but just within Vim, most tend to avoid mouse use. – Ingo Karkat Apr 29 '14 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.