tags:

views:

156

answers:

2

Can standard mouse input be customized in vim (in my case gvim)? Plugins are acceptable options too.

I'm specifically interested in "overriding" a double-click on a word, so that instead of just highlighting the word, gvim does a search and thus highlights all instances of this word in the file. I've seen this functionality in other editors and found it very useful.

+1  A: 

I don't regarding mouse, but you can press */# to search word under cursor forward/backward.

dimba
I'm interested in mouse specific input. When I'm just reading source files, I tend to just use the mouse to scroll around.
Marcin
+5  A: 

See :help double-click. It should have everything you need. For example from the help page:

An example, for using a double click to jump to the tag under the cursor:

:map <2-LeftMouse> :exe "tag ". expand("<cword>")<CR>
Neg_EV
Oh and for you specific mapping this will do, although there are other ways as well.map <2-LeftMouse> :normal *<CR>
Neg_EV
+1 for your comment. Is there a way to do this so it doesn't automatically jump to the next instance of the word, and instead stay on current line?
Marcin
try::map <2-LeftMouse> :let @/ = expand("<cword>")<CR>
Neg_EV
actually do::map <2-LeftMouse> :let @/ = expand("<cword>")<CR>:set hlsearch<CR>
Neg_EV
The first would only work if you had something highlighted already. The second turns the highlighting on after setting the search word.
Neg_EV
Perfect. I'll have to research what all these commands do (map, let, @) to better understand how this works. Thanks!
Marcin