0

There is probably an easy solution for this, but here it goes : whenever I do a git commit, an error appears (copied hereunder). Vim then starts, some of my .vimrc features are enabled, some are not.

Since I don't need all of my .vimrc options to just write a commit, I thought that a possible solution for that would be to create a .vimrc file specifically for git commits, but I don't know how that should be done?

Error :

Error detected while processing /home/homehome/.vimrc:
line  106:
E518: Unknown option: foldenable
  • 4
    Note that foldenable is local to a window thus you shouldn't put it in your vimrc at all since the setting will not be applied on all of the windows. I also think that if your problem is that you have an error in your vimrc you should correct the error rather than changing your vimrc :) – statox Jan 25 '18 at 10:53
  • @statox Thank you very much for the 'local window' precision ! Regarding the error in the .vimrc, it seems however that the error only pops up when Vim is called from git commit, and never happens otherwise... Also, where should I put the foldenable option then ? – Feffe Jan 25 '18 at 10:57
  • You're welcome :) Does that solve your problem with your git commits? – statox Jan 25 '18 at 10:59
  • @statox not yet, I posted the comment without meaning it, then edited it to explain more in details, which I guess you thus did not see :) – Feffe Jan 25 '18 at 11:09
  • 2
    Are you certain you're using the same Vim executable in both instances? What does :version report in regular Vim and in git commits? – Rich Jan 25 '18 at 11:29
4

It is strange that the error just appear with git commit -- I guess you have two versions of Vim installed, and the one used by git is older/have less features and thus complain about that option.

You could try to configure you git editor passing the full path of the Vim you normally use.

In any case, I agree with the comments on your question: you should fix your vimrc instead of creating another one. And that setting a option which is local to window doesn't make much sense -- it would be better in a filetype-plugin or in a modeline.

As a last resort you could check if the option is available before setting it. In :help 'foldenable' it says it requires the folding feature, so you can if that feature using has(), or maybe check directly the option as explained in :help exists().

  • 1
    "Re"-telling git that I wanted Vim for editor (git config --global core.editor vim) worked. Thanks ! – Feffe Jan 25 '18 at 13:05
  • @Feffe glad it worked! – mMontu Jan 25 '18 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.