1

I've got a plugin called YouCompleteMe installed in vim. When vim starts with this plugin installed, it will raise a warning if the version of vim is under the minimum required.

I'm using vim 7.3.754, which is able to run YCM, but when I execute commands like git merge or git commit --amend, I see the warning:

YouCompleteMe unavailable: requires Vim 7.3.584+

My question is: why is git using a different version of vim than zsh, and how can I get it to use the same version?

2 Answers 2

5

According to man git-var git determines the editor using this sequence:

The order of preference is the $GIT_EDITOR environment variable, then core.editor configuration, then $VISUAL, then $EDITOR, and then finally vi.

I suppose you haven't set any of these variables, so git takes vi -- which usually runs vim in the vi compatible mode (depending on you distribution).

So, check where yor up-to-date vim is located:

which vim

Then define this executable as the default git editor:

git config --global core.editor /usr/bin/vim

Alternatively, it's no bad idea to set $VISUAL. Other programs also use this environment variable, too. To do that, include

export VISUAL=/usr/bin/vim

in your ~/.zshrc and do source ~/.zshrc.

6
  • Do you have any idea why git might have been ignoring $VISUAL, $EDITOR and ~/.gitconfig? The only way that I could get this to work was to explicitly set $GIT_EDITOR.
    – Sean Hill
    Oct 4, 2014 at 20:51
  • @SeanHill: Have you checked if you have the core.editor defined somewhere in your git config? As this take precedence over $VISUALand $EDITOR this might look as if these environment variables are ignored.
    – mpy
    Oct 4, 2014 at 21:00
  • Yeah, setting core.editor to /usr/local/bin/vim was ignored also. Git was using another version of vim no matter what I put in $VISUAL, $EDITOR or core.editor. The only thing it will respect is $GIT_EDITOR.
    – Sean Hill
    Oct 4, 2014 at 21:14
  • To be clear, it was using vi even though I had set the other variables and $GIT_EDITOR was not set at all. I'm using version 2.1.1 of git.
    – Sean Hill
    Oct 4, 2014 at 21:16
  • @SeanHill: Probably it's best if you open up a own question on your issue.
    – mpy
    Oct 5, 2014 at 16:58
2

Git uses either $EDITOR or $VISUAL or $GIT_EDITOR or the editor you specified for core.editor in ~/.gitconfig.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .