Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Focus follow mouse in vim

Tags:

vim

mousemove

I am aware that the mousefocus option is only supposed to work in gVim. But I was wondering, if it's possible to have the console Vim switch to different windows in response to mouse clicks, would it be not possible to easily add following mouse movement to it, too?

I'm an xmonad user, I love the focus following the pointer feature, I do a lot of pdf viewing and browsing while writing in Vim, and I'd be so much happier if I didn't have to keep mentally switching back and forth between two different types of focus changing.

If that's completely not possible, I guess opening new Vim windows (as with :split) in new instances of the terminal is no easier to do?

like image 660
Kamil S. Avatar asked Dec 04 '12 21:12

Kamil S.


1 Answers

It would not be at all simple to add this. Using the mouse within the terminal works by vim sending control codes to the terminal requesting that mouse actions be sent as part of the input stream. Terminals only report clicks not changes in the pointer position, so vim has no way of knowing where the mouse is.

With major changes it would likely be possible for a vim with X support to get pointer activity directly from the X server, but that would likely be reported by pixel rather than by character so further work would need to be done before it could determine which vim window is currently under the pointer.

like image 78
qqx Avatar answered Sep 20 '22 06:09

qqx