1

Let me start off with saying that I do try to use the mouse in vim as little as possible, but there are times that I will end up using it to click around or highlight something.

With that said, here's the problem I'm having. For the most part, I'll have my terminal (terminator) maximized on one of my monitors and I'll generally have vim open with 2 or 3 windows split vertically on it. The problem comes up when I click on the right-most window; it will instead move the cursor to the left-most window. Because I rarely click, it really throws me off when it's not the expected behavior and I can never get used to it.

I searched around for what the problem could be and found that there was a problem with xterm and mouse clicks past the 220th column in the terminal. Supposedly, it has since been fixed. I'm able to more easily test the problem by just opening vim in a max size terminal and creating a ~250 character line. I can't click on any character past the 220th column. After searching around, I found that many people suggested setting "ttymouse=sgr" in .vimrc. I tried that, but it didn't change anything.

I did mention that I'm using terminator as my terminal. I'm not seeing this behavior in gnome-terminal, but I would really prefer to stick with terminator. I'm not super familiar with how mouse integration works with programs inside the terminal, but I imagine something about the terminal capabilities is different between terminator and gnome-terminal.

I'm running Ubuntu 14.04 LTS.

  • I also have this in urxvt (a terminal emulator) so it's not a terminator problem – boobie_goodness Dec 11 '15 at 10:04
2

Terminator and Gnome-terminal use the same terminal emulation widget called Vte. However, Gnome-terminal uses a newer, Gtk+-3 based version of it, whereas Terminator relies on an older Vte, based on Gtk+-2.

Legacy mouse protocol only supports row and column values up to 223. The extended version was added to Vte's Gtk+-3 branch.

If you're a bit adventurous, you can switch to Terminator's new Gtk+-3 based version (https://code.launchpad.net/~gnome-terminator/terminator/gtk3). It's in active development nowadays, and have received many improvements and fixes over the one you're using, but there are 1 or 2 noticeable regressions right now that we're working on (most notably: wrong sizes after a double click on a separator, or after a rotate operation). But after all, I think you would like the improvements.

It requires an even newer version of Vte than shipped by Trusty. You can try if vte2.91 package from Gnome3 Staging (https://launchpad.net/~gnome3-team/+archive/gnome3-staging/+packages) for a newer Ubuntu installs fine, I'm not sure. Or you can compile and install from vte-0.42 tarball (ftp://ftp.gnome.org/pub/GNOME/sources/vte/) (./configure --prefix=/usr && make && sudo make install), I did this the other day and I can guarantee that this works, all you need to do is install some dependencies that are available as Trusty packages, although sometimes it's a bit tricky to figure out the required package (along the lines of python, gir, libgirepository...).

Installing newer Vte this way won't overwrite your previous ones, you'll have three versions coexisting.

With the newer one in place, Terminator's Gtk+-3 version from bzr should start up straight away.

  • I assume the behavior would be same for tmux too, right? In my case, I have my layout as ||vim-vert-split1|vim-vert-split2|vim-vert-split3||tmux-vert-pane2|| with each split/pane 80 columns wide. Workflows involving selection/scrolling in tmux pane2 work normally. Any ideas why'd that be? – UltraInstinct Sep 11 '17 at 20:36
  • @SuperSaiyan I'm not sure what's your problem; are you asking why it works normally? What's the problem? :) Anyway, in case you have a trouble, I recommend that you post a new question. – egmont Sep 11 '17 at 21:50
  • Your answer kind of solves my problem, +1! I'm hesitant on creating a new question because this is a comment/question about your answer. Let me rephrase my question: "If programs like vim can't handle mouse interactions beyond col 223, how is it that tmux is able to handle it (like text selection) in the above configuration? The mouse interactions happen at col > (80*3). I'd assume tmux also uses the same vte version." – UltraInstinct Sep 11 '17 at 22:19
  • 1
    First, I'm pretty sure vim can handle it :) but let's assume it cannot. Tmux enables the relevant extension, receives the mouse coordinates in the new format, however, it obviously needs to adjust them. It has to subtract the x and y offset of the given pane, as well as transfer to the format that vim is requesting (probably the legacy format which can only handle up to 223, but that's fine since after subtracting the pane's offset the coordinates are below that). – egmont Sep 12 '17 at 10:42

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.