4

I am following the easy git guide at nettuts easy git guide

I initialised an empty git instance in my ~/ directory and then added my .vimrc and my .vim/ files.

git add .vimrc
git add .vim

However when I do the git commit command I end up with what seems unrelated error messages.

sayth@linux-kt34:~> git commit
Error detected while processing /home/sayth/.vimrc:
line  203:
E319: Sorry, the command is not available in this version: py << EOF
line  204:
E492: Not an editor command: import os.path
line  205:
E492: Not an editor command: import sys
line  206:
E492: Not an editor command: import vim
line  207:
E15: Invalid expression: 'VIRTUAL_ENV' in os.environ:
line  224:
E171: Missing :endif
Press ENTER or type command to continue

If I press enter I get taken to a file. What am I doing wrong with this.

EDIT: have removed virtualenv ref from .vimrc. Never noticed the error because i was using gvim which never dislpayed the error.

Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
sayth
  • 6,696
  • 12
  • 58
  • 100
  • This problem is related with you /home/sayth/.vimrc. Paste it so we can comment – ssedano Jan 03 '12 at 09:44
  • my vimrc is probably too long to paste here. Edit above I removed the offending virtualenv section from the vimrc – sayth Jan 03 '12 at 12:38
  • You can past your `.vimrc` to e.g. https://gist.github.com and link to it. – Zsolt Botykai Jan 03 '12 at 13:01
  • for reference my vimrc is here https://github.com/flebber/MyVim/blob/master/.vimrc – sayth Jan 03 '12 at 13:01
  • For reference, I had this problem (errors when vim started from git, but not normally) on a server, although not python related. I was getting errors about "no mouse support", "cannot find colour scheme", etc. This was because the (oldish) system was running Vim 7.0, and so I had compiled vim 7.3 in my home directory, and was using that. Git, on the other hand, appears to use the system vim (confimed by checking `:version`). This is pretty annoying. It can be fixed by forcing git to use your self-compiled version: `git config --global core.editor '~/bin/vim'` – naught101 Jun 26 '12 at 04:34

3 Answers3

5

When you run git commit without specifying a commit message on the command line, it will launch an editor (in your case vim) so that you can enter one. Those errors that you see are from vim, reporting that you have errors in your .vimrc file. You should get the same errors if you just launch vim normally.

Mark Longair
  • 446,582
  • 72
  • 411
  • 327
  • Removed section from vimrc, then comitted with git commit -am 'first commit' which seems to have worked. – sayth Jan 03 '12 at 12:41
  • 2
    I'm getting vim errors that I *don't* get if I launch vim normally. Both occur inside a function declaration - as if it's attempting to execute the function, even though my vimrc never calls it. Is it possible that git is calling a different Vim that somehow doesn't support functions? Or is something else going on? – Paul Brinkley Sep 21 '17 at 18:12
3

Your vim installation does not have python support. If you run the command

vim --version | grep python

you should see +python, otherwise it means python is missing from the vim installation.

fluca1978
  • 3,968
  • 2
  • 15
  • 15
  • sayth@linux-kt34:~> vim --version | grep python +persistent_undo +postscript +printer +profile -python -python3 +quickfix – sayth Jan 03 '12 at 12:25
1

This happens because git commit choose the editor 'vi'.
You can setting it to use 'vim', with command:

git config --global core.editor "vim"


More detials can be found [here]:How do I make Git use the editor of my choice for commits?

Donggua
  • 11
  • 1
  • 3