In Vim, why doesn't my mouse work past the 220th column?

I tend to maximize a terminal to one screen, and vertically split several windows in Vim. Everything works fine for the first few windows on the left, but clicking past about the 220th column in the terminal doesn't work correctly. Any mouse clicks past column 220 seem to be wrapping around to column 1. I've tested in xterm, urxvt, and Gnome terminal with and without tmux/screen; always the same behavior. If I greatly increase the size of the font in Gnome terminal, I can click on the last column (although it is no longer past column #220).

If I run a command in a terminal that prints to standard output, I can click all the way to the right of the terminal. The problem does seem to be related to Vim.

I have set mouse=a in .vimrc. I'll post the entire file on request, but it doesn't seem to have anything else related to the mouse.

It's probably irrelevant, but I'm running Xmonad+Gnome. Thanks in advance.


This has been fixed in Vim 7.3.632. See :h sgr-mouse. Or just put this in your ~/.vimrc:

set ttymouse=sgr

If you want to be compatible with versions that don't have mouse_sgr compiled in, use:

if has("mouse_sgr")
    set ttymouse=sgr
else
    set ttymouse=xterm2
end

To see if your version of Vim has mouse_sgr, run vim --version from the command-line, or in Vim, enter :version, and look for +mouse_sgr.

If you're using older versions of screen, or terminal emulators that don't support SGR, you may need to upgrade or switch. These settings work with all new versions of screen, tmux, gnome-terminal, PuTTY/KiTTY, iTerm2, and Terminal.app, using TERM=xterm-256color or screen-256color.

Update: If you're using neovim, SGR support is enabled by default.


Edit:
I deleted the bug report, as that tracker was for the website, not the text editor.

In looking in the correct place for an existing bug report, I found this: http://groups.google.com/group/vim_dev/browse_thread/thread/4c137e64d2032441/b3993eaa89589619?lnk=gst&q=mouse#b3993eaa89589619

To summarize, it was an xterm limitation that has been lifted. However, Vim does not yet support columns longer than 223.


Original:
This seems to be a bug, as supported by comments made by redstreet. I filed a bug report:

https://sourceforge.net/tracker/?func=detail&aid=3389331&group_id=27891&atid=391887


A few years later, the bug still seems to be present. The solution I found is neovim: a modern refactor of vim. Among other features, this bug has been resolved.

I simply copied my .vimrc into .nvimrc, and my plugins just worked with nvim. Maybe I'll just keep using that.