Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim says "No mouse support", but only when I run git commit

Tags:

git

vim

I like using the mouse with vim, so I have mouse support enabled in my .vimrc. This works just fine most everywhere, but whenever I run git commit on a specific server (Appa), I get an error message:

[tswett@appa git]$ git commit
Error detected while processing /home/tswett/.vimrc:
line    1:
E538: No mouse support: mouse=a
Press ENTER or type command to continue
Aborting commit due to empty commit message.
[tswett@appa git]$

I end up with a vim session that has no mouse support and no syntax highlighting.

If I run git commit on a different server, or on my local machine, I do have mouse support and syntax highlighting. Likewise, whenever I use vim to edit anything else on Appa, I have mouse support and syntax highlighting. If I remove the set mouse=a line from .vimrc and then run git commit on Appa, I no longer get an error message, but I also don't get syntax highlighting, either.

How can I get vim, git commit, and Appa to all play nice with each other?

Appa's operating system is RHEL 6.3 (Santiago); Appa's vim is version 7.2; and Appa's git is version 1.7.1. Here's my .vimrc (identical across all machines): https://github.com/tswett/setup/blob/c84c8908a04a1d925d90da3da4f2fc83bf56172b/.vimrc

like image 887
Tanner Swett Avatar asked Aug 08 '12 18:08

Tanner Swett


2 Answers

Does vim on Appa otherwise behave correctly? That is, do you have the problem whenever you run vim, or only when using git commit?

If the former:

Are you sure that git commit is running vim? Many applications default to using vi in the absence of any other configuration, and it's typical for vi to either (a) a very minimal version of vim missing lots of fancy features or (b) something completely different.

Try explicitly setting core.editor to vim and see what happens:

git config --global core.editor vim

Alternatively, you can also set your EDITOR and VISUAL environment variables.

like image 61
larsks Avatar answered Nov 01 '22 21:11

larsks


Mouse support can be enabled or disabled in specific vim builds. You can look at which features are enabled/disabled using: :version. On the Appa machine you'll probably see -mouse in the list.

The only solution is to use a vim that's been built with mouse support,. Unless you control the server this means:

  • compiling it yourself or obtaining a compiled executable for the platform,
  • keeping it in a user-local bin directory, and
  • setting the EDITOR environment variable to point to your own vim.
like image 1
pb2q Avatar answered Nov 01 '22 20:11

pb2q