Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim/MacVim: when I scroll with mouse, the text cursor moves too!

I've been getting used to Vim/MacVim for the last few weeks. One of main problems I seem to be having is when I scroll around using the mouse (especially when I'm trying to select large portions of text) the text insertion cursor moves too and doesn't stay where it was (like in TextMate for example). This means I've selected a large piece of text, when I scroll back up to review my selection the cursor will move which messes with the selection that I've made.

I do realise I should get used to text selection with visual mode, and I am one bit of a time, but sometimes it's the best tool to use the mouse.

Is there a way of fixing this behaviour?

like image 882
littlejim84 Avatar asked Nov 16 '10 15:11

littlejim84


1 Answers

:help scrolling tells you:

These commands move the contents of the window. If the cursor position is moved off of the window, the cursor is moved onto the window (with 'scrolloff' screen lines around it).

So basically I would say that it is not possible to leave the cursor where it was when you are scrolling. The cursor is always visible in your window, and therefore your visual selection will extend.

Probably you would like to xnoremap <ScrollWheelUp> <esc><ScrollWheelUp> and same for ScrollWheelDown. Use then gv to restore your selection.

like image 83
Benoit Avatar answered Oct 23 '22 15:10

Benoit