I'm just starting to use Vundle and I'm running into an error when editing a Git message using the .vimrc setup from the README. When I try to save any git message in vim, I get the following error.
$ git commit
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.
I've tracked this down to the initial filetype off directive (marked as required in the README). I don't understand why its causing this issue, but after commenting out the line, but this re-enabled Git commit editing in vim.
Can you shed some light on why its "required" to disable filetype detection before using vundler? And then to re-enable it (using filetype plugin indent on) later on?
FWIW, my vim version:
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 24 2011 20:00:09)
Compiled by [email protected]
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype
+path_extra -perl +persistent_undo +postscript +printer -profile -python
-python3 +quickfix +reltime -rightleft -ruby +scrollbind +signs +smartindent
-sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses
I think it's to enable Vundle to bypass $VIMRUNTIME when installing & then you re-set to enable the use of filetypes.
See:
h: filetype
I'm sure our author can elucidate further :-)
@codyaray as @phildobbin it's required to set filetype detection properly.
It's usually hard to say what causing issues for you without looking .vimrc.
Also i'd like to know what $EDITOR is set to.
Closing issue, as suspect it's just a configuration issue.
Feel free to comment if you still having issues.
git config --global core.editor /usr/bin/vim solved it for me.
git config --global core.editor $(which vim)
git config --global core.editor $(which vim) works. Very strange however because I was always using /usr/bin/vim. Whatever I guess.
This worked for me too:
git config --global core.editor $(which vim)
git config --global core.editor $(which vim)
that works
I just went through this process as well:
git commit$EDITOR, which is set to vigit config --global core.editor $(which vim)), notice that it works$EDITOR from vi to /usr/bin/vimI'm using Vim 7.3. Thanks for Vundle. Looking forward to using it.
@cbeams what does which vim and which vi give you?
Also, can you provide the output of:
vim --version
and
vi --version
$ vi --version | head -1
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)
$ vim --version | head -1
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)
$ ls -l $(which vi)
lrwxr-xr-x 1 root wheel 3 Feb 18 06:44 /usr/bin/vi -> vim
$ ls -l $(which vim)
-rwxr-xr-x 1 root wheel 1472736 Feb 18 06:43 /usr/bin/vim
After reading the blog post in step 5, it gets even darker. To be honest I haven't got the slightest clue of what's going on :unamused:
If the vim executable's name is vi, vim will run in vi mode. This is mentioned in the manpage under the option -v and seems to be causing this.
This gist proposes turning filetype on and then off to solve this issue. I have been using that solution for more than 8 months now without any issues (Ubuntu and OS X).
It might be a good idea to change the first two lines of the README's example .vimrc to:
set nocompatible " be iMproved, required
filetype on " required for compatibility with Mac OS X, See issue #167
filetype off " required
i spent some time looking into this and here's what's what i found out:
first, i started with just this in my vimrc:
filetype off
and the error shows up as expected:
禄 /usr/bin/vi --version | head -3; /usr/bin/vi -u vimrc -c q; echo $?
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec 19 2013 15:19:49)
Compiled by [email protected]
Normal version without GUI. Features included (+) or not (-):
1
that config causes vim to load ftoff.vim (you can see what files are loaded at startup by running vim --startuptime <logfile>):
" Vim support file to switch off detection of file types
"
" Maintainer: Bram Moolenaar <[email protected]>
" Last change: 2001 Jun 11
if exists("did_load_filetypes")
unlet did_load_filetypes
endif
" Remove all autocommands in the filetypedetect group
silent! au! filetypedetect *
if you remove silent!, you can see the error that vim is generating:
禄 /usr/bin/vim -u vimrc -c q
Error detected while processing /usr/share/vim/vim73/ftoff.vim:
line 11:
E216: No such group or event: filetypedetect *
Press ENTER or type command to continue
setting filetype on works around the problem because it causes the filetypedetect group to exist and no error to be generated.
so why does running as vi return a non-zero exit code when vim doesn't? i didn't spend the time to trace it down exactly, but that bug was fixed somewhere in the post 7.3 patches. if you brew install vim, which currently installs 7.4.430 the problem goes away:
禄 /usr/local/bin/vi --version | head -3; /usr/local/bin/vi -u vimrc -c q; echo $?
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 15 2014 15:48:26)
MacOS X (unix) version
Included patches: 1-430
0
so, you can resolve this issue by setting your editor to vim (instead of vi), setting filetype on before setting it off, or upgrading your version of vim.
I hit this too. The workaround git config --global core.editor $(which vim) worked for me.
git config --global core.editor $(which vim) make sense to me
Confirmed here too. For whatever its worth, this happened immediately after upgrading to Yosemite. It doesn't make sense because I'm using a homebrew-installed version of vim (which lives in /usr/local) instead of the /usr/bin version provided by the OS.
git config --global core.editor $(which vim)
This works in my case. Platform Mac OS X 10.9.5
Just chiming in to say this only happened to me _after_ installing the homebrew version of vim. Worked fine before hand. Hopefully that's a hint.
Oh, and git config --global core.editor $(which vim) worked to solve the issue.
I tried git config --global core.editor $(which vim) and it doesn't work for me.
The error message are:
/usr/bin/mate -w: /usr/bin/mate: No such file or directory
error: There was a problem with the editor '/usr/bin/mate -w'.
Please supply the message using either -m or -F option.
Just hit this, thank God for you guys. Solution works. :D
Like many others posting here, I'm using a version of Vim installed by Homebrew on OS/X.
The problems wouldn't be happening because Git's not reading symlinked $EDITOR paths, would it...? Homebrew executables are symlinked to /usr/bin/, sooo...
thank you @ruebenramirez 馃帀
git config --global core.editor $(which vim) worked for me too
git config --global core.editor /usr/bin/vim
solved my problem. Thanks!
I had this problem repeatedly when using ":W" by error instead of ":w". Using ":w" after having used ":W" once did not fix the problem, after saving and closing, the commit message was lost.
git config --global core.editor /usr/bin/vim fixed it reliably for me.
For me setting core.editor wasnt sufficient. I had a complicated .vimrc which had the following.
filetype off
I replaced that with
filetype on
filetype off
It looks dumb but this totally worked. See @cameronr comment for more detailed explanation. Kudos to him!
how to recover the lost git message when this happened?
@azhong00 you can find it int .git/COMMIT_EDITMSG but only if you haven't used git commit since then
A more general solution is to set export EDITOR=$(which vim) in your .bashrc. Git will use this environment variable if core.editor is not set and other programs will know to use Vim too.
i have commit problem with my git cmd
@cameronr's solution here is the best IMO. I ran into this with a git commit but then I also it hit using kubectl edit on a kubernetes resource. The git config workaround will fix the problem in git but it'll still occur in other instances that invoke an editor and use the output. Setting filetype on before setting filetype off in the .vimrc resolves it in all situations.
this works for me too
Encounter this issue in Mac, the git config --global core.editor $(which vim) did NOT work for me, but setting ~/.vimrc works! Add below in it:
filetype on
filetype off
I know this is an old one, but it helped out.
On Windows, make it something like so to fix:
$ git config --global core.editor "C:/Program\ Files\ \(x86\)/Notepad\+\+/notepad\+\+.exe"
If you copy your path from Windows Explorer, make sure to replace all Directory Separators (\) with forward slash / and use the back slash to escape any non-alphanumeric charachters, such as in the example above for space char, +, ( and ).
Most helpful comment
git config --global core.editor /usr/bin/vimsolved it for me.