Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

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.

like image 912
bhinesley Avatar asked Aug 09 '11 18:08

bhinesley


1 Answers

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.

like image 163
Jim Stewart Avatar answered Nov 10 '22 16:11

Jim Stewart