1

I just installed vim-plug to use the doxygen plugin. Added

call plug#begin()
    Plug 'vim-scripts/DoxygenToolkit.vim'
call plug#end()

to the .vimrc (_vimrc because Win10..). Using the doxygen plugin from gVim works just fine, no problem there.

Now if open vim from the git-bash shell (either from calling vim or from git commit) I get an error:

$ vim                                                                                                                                                                                                                                        
Fehler beim Ausführen von "/c/Users/my.name/_vimrc":                                                                                                                                                                                      
Zeile   37:                                                                                                                                                                                                                                  
E117: Unbekannte Funktion: plug#begin                                                                                                                                                                                                         
Zeile   39:                                                                                                                                                                                                                                  
E492: Kein Editorbefehl: Plug 'vim-scripts/DoxygenToolkit.vim'                                                                                                                                                                               
Zeile   41:                                                                                                                                                                                                                                  
E117: Unbekannte Funktion: plug#end                                                                                                                                                                                                          
Betätigen Sie die EINGABETASTE oder geben Sie einen Befehl ein

Sorry for the German, it basically doesn't recognize plug#begin as a function and Plug 'vim-scripts/DoxygenToolkit.vim' as an editor command. Vim still works after pressing enter, just the :Dox command doesn't work in any Vim started from the git-bash.

I'm using the shell mostly for git and use the gVim for most file editing and I don't need :Dox in the git commit message editor. So this is just mildly annoying. Is there a way to fix this or at least turn of the message and extra key press?

Edit: :version outputs

From git-bash vim

:version                                                                                                                                                                                                                                                 
VIM - Vi IMproved 8.2 (2019 Dec 12 kompiliert am Sep 21 2021 16:13:20)                                                                                                                                                                       
Inklusive der Patches: 1-3441                                                                                                                                                                                                              
Übersetzt von <https://www.msys2.org/>                                                                                                                                                                                                      
Riesige Version ohne GUI. Ein- (+) oder ausschließlich (-) der 
Eigenschaften:                                                                                                                                                                
+acl               +cindent           +cursorshape       
+file_in_path      +job               +menu              
+mouse_urxvt       +popupwin          +signs             
-tag_any_white     +user_commands     +writebackup                
+arabic            -clientserver      +dialog_con        
+find_in_path      +jumplist          +mksession         
+mouse_xterm       +postscript        +smartindent       -tcl               
+vartabs           -X11                        +autocmd           
+clipboard         +diff              +float             +keymap            
+modify_fname      +multi_byte        +printer           -sodium            
+termguicolors     +vertsplit         -xfontset                   
+autochdir         +cmdline_compl     +digraphs          +folding           
+lambda            +mouse             +multi_lang        +profile           
-sound             +terminal          +virtualedit       -xim                        
-autoservername    +cmdline_hist      -dnd               -footer            
+langmap           -mouseshape        -mzscheme          -python            
+spell             +terminfo          +visual            -xpm                        
-balloon_eval      +cmdline_info      -ebcdic            +fork()            
+libcall           +mouse_dec         +netbeans_intg     
+python3/dyn       +startuptime       +termresponse      
+visualextra       -xsmp                       +balloon_eval_term 
+comments          +emacs_tags        +gettext           +linebreak         
-mouse_gpm         +num64             +quickfix          
+statusline        +textobjects       +viminfo           - 
xterm_clipboard            -browse            +conceal           
+eval              -hangul_input      +lispindent          
-mouse_jsbterm     +packages          +reltime            
-sun_workshop      +textprop          +vreplace          
-xterm_save                 ++builtin_terms    +cryptv            
+ex_extra          +iconv             +listcmds          
+mouse_netterm     +path_extra        +rightleft         +syntax            
+timers            +wildignore                                    
+byte_offset       +cscope            +extra_search      
+insert_expand     +localmap          +mouse_sgr         +perl/dyn          
+ruby/dyn          +tag_binary        +title             +wildmenu                                      
+channel           +cursorbind        -farsi             +ipv6              
-lua               -mouse_sysmouse    +persistent_undo   
+scrollbind        -tag_old_static    -toolbar           +windows                                                 
System-vimrc-Datei: "/etc/vimrc"                                                                                                                                                                                                
Benutzer-vimrc-Datei: "$HOME/.vimrc"                                                                                                                                                                                                  
zweite Benutzer-vimrc-Datei: "~/.vim/vimrc"                                                                                                                                                                                                          
Benutzer-exrc-Datei: "$HOME/.exrc"                                                                                                                                                                                                        
defaults Datei: "$VIMRUNTIME/defaults.vim"                                                                                                                                                                                                  
Voreinstellung für $VIM: "/etc"                                                                                                                                                                                                                  
und für $VIMRUNTIME: "/usr/share/vim/vim82"                                                                                                                                                                                         
Übersetzt: gcc -c -I. -Iproto -DHAVE_CONFIG_H - I/usr/include/ncursesw -march=x86-64 -mtune=generic -O2 -pipe -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1                                                                              Linken: gcc -L. -pipe -fstack-protector-strong -pipe -Wl,--as-needed -o vim.exe -lm -lncursesw -liconv -lacl -lintl -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong -L/usr/lib/perl5/core_perl/CORE -lperl -lpthread -ldl -lcrypt  

                                                                                

gvim output:

VIM - Vi IMproved 9.0 (2022 Jun 28 kompiliert am Jun 28 2022 13:09:53)
MS-Windows 32 Bit GUI Version mit OLE-Unterstützung
Übersetzt von appveyor@APPVYR-WIN
Riesige Version mit GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:
+acl                +channel            +cscope             +eval               -hangul_input       +linebreak          +multi_byte_ime/dyn +popupwin           +scrollbind         +tag_binary         +timers             +visualextra        -xterm_save
+arabic             +cindent            +cursorbind         +ex_extra           +iconv/dyn          +lispindent         +multi_lang         -postscript         +signs              -tag_old_static     +title              +vreplace           
+autocmd            +clientserver       +cursorshape        +extra_search       +insert_expand      +listcmds           +mzscheme/dyn       +printer            +smartindent        -tag_any_white      +toolbar            -vtp                
+autochdir          +clipboard          +dialog_con_gui     -farsi              +ipv6               +localmap           +netbeans_intg      +profile            +sodium/dyn         -tcl                +user_commands      +wildignore         
+autoservername     +cmdline_compl      +diff               +file_in_path       +job                +lua/dyn            +num64              +python/dyn         +sound              -termguicolors      +vartabs            +wildmenu           
+balloon_eval       +cmdline_hist       +digraphs           +find_in_path       +jumplist           +menu               +ole                +python3/dyn        +spell              +terminal           +vertsplit          +windows            
-balloon_eval_term  +cmdline_info       +directx            +float              +keymap             +mksession          +packages           +quickfix           +startuptime        -termresponse       +vim9script         +writebackup        
+browse             +comments           -dnd                +folding            +lambda             +modify_fname       +path_extra         +reltime            +statusline         +textobjects        +viminfo            -xfontset           
++builtin_terms     +conceal            -ebcdic             -footer             +langmap            +mouse              +perl/dyn           +rightleft          -sun_workshop       +textprop           +virtualedit        -xim                
+byte_offset        +cryptv             +emacs_tags         +gettext/dyn        +libcall            +mouseshape         +persistent_undo    +ruby/dyn           +syntax             -tgetent            +visual             +xpm_w32            
          System-vimrc-Datei: "$VIM\vimrc"
        Benutzer-vimrc-Datei: "$HOME\_vimrc"
 zweite Benutzer-vimrc-Datei: "$HOME\vimfiles\vimrc"
 dritte Benutzer-vimrc-Datei: "$VIM\_vimrc"
         Benutzer-exrc-Datei: "$HOME\_exrc"
 zweite Benutzer-exrc-Datei: "$VIM\_exrc"
         System-gvimrc-Datei: "$VIM\gvimrc"
       Benutzer-gvimrc-Datei: "$HOME\_gvimrc"
zweite Benutzer-gvimrc-Datei: "$HOME\vimfiles\gvimrc"
dritte Benutzer-gvimrc-Datei: "$VIM\_gvimrc"
      defaults Datei: "$VIMRUNTIME\defaults.vim"
           System-Menü-Datei: "$VIMRUNTIME\menu.vim"
Übersetzt: cl -c /W3 /GF /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_SOUND -DFEAT_NETBEANS_INTG -DFEAT_JOB_CHANNEL -DFEAT_IPV6   -DFEAT_XPM_W32 -DHAVE_SODIUM -DDYNAMIC_SODIUM -DDYNAMIC_SODIUM_DLL=\"libsodium.dll\" /I "C:\libsodium\include" -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /source-charset:utf-8 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG /arch:IA32 /Zl /MT /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_MSWIN -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua54.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python310.dll\" -DFEAT_MZSCHEME -I "C:\racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_da32rk.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_da32rk.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl532.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby300.dll\" -DRUBY_VERSION=30 -DFEAT_HUGE /Fd.\ObjGXOULYHRZi386/ /Zi
Linken: link /nologo /opt:ref /LTCG oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib user32.lib  /machine:i386 version.lib  winspool.lib comctl32.lib  libcmt.lib oleaut32.lib  /nodefaultlib:lua54.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python310.lib    winmm.lib WSock32.lib Ws2_32.lib xpm\x86\lib-vc14\libXpm.lib  /PDB:gvim.pdb -debug
4
  • Which directory did you install vim-plug to? Note that git-bash will look in Linux-style ~/.vim while gVim for Windows will look in ~/vimfiles. BTW, better to use a vimrc in either of these directories than a standalone .vimrc (or _vimrc)
    – Friedrich
    Commented Sep 20, 2023 at 7:25
  • 1
    You are using two different Vims. Could you add the full output of :version of both to your question?
    – romainl
    Commented Sep 20, 2023 at 7:26
  • 2
    Another hint: at least in git-bash, you can do LANG=C vim to hide turn the German error messages into nice English ones.
    – Friedrich
    Commented Sep 20, 2023 at 7:39
  • @Friedrich should be in /c/Users/my.name/vimfiles but they should both be using the same vimrc? in gVim :Dox works, and git-bash vim complains about plug#begin?
    – Max
    Commented Sep 20, 2023 at 7:55

1 Answer 1

3

As pointed out by romainl in the comments, you have two versions of Vim installed:

  • Vim 9.0 with GUI for Windows you probably installed yourself
  • Vim 8.2 without GUI that came on top of git-bash (on a side note, Git for Windows 2.40 comes with Vim 9.0 so consider upgrading)

Git-bash lives in it's own happy Unix-y world. Its version of Vim will source ~/.vimrc or ~/.vim/vimrc and not care about ~/vimfiles etc.

The whole process is explained in :help vimrc. Read a little down and you will find this note:

Note: For Unix and Amiga, when ".vimrc" does not exist, "_vimrc" is also tried, in case an MS-DOS compatible file system is used. For MS-Windows ".vimrc" is checked after "_vimrc", in case long file names are used.

So git-bash's Vim will fall back to reading ~/_vimrc in which it will find commands like call plug#begin() which it cannot process. It is blissfully unaware of your installation of vim-plug in ~/vimfiles. Hence the error message.

You should be able to diagnose the problem when you issue the :scriptnames and :set rtp? commands and see how the output differs between your Vim versions.

You have a couple of options to remedy the situation. I would recommend to first move your ~/_vimrc to ~/vimfiles/vimrc. This will prevent the fallback from kicking in and make your Vim configuration self-contained. As an added benefit - you can easily version the whole directory tree using Git.

To use the same configuration in git-bash, you need to keep the two directories ~/vimfiles and ~/.vim in sync. As long as you don't have any OS-specific stuff in them, you can simply symlink or copy one configuration to the other one.

If you have OS-specific information in them (like C:\ paths), you can either take care of them in your vimrc (if has('win32')etc.) or only merge the OS-independent parts using standard diff/merge tools.

Depends largely on how much work you're willing to invest versus how much change you anticipate in your Vim configuration directory.

To be brutally honest, I haven't found a solution myself that I am 100% happy with. For now, I mostly use two Git repos on different branches and pull changes as I see fit. While I dislike the duplication on general principle, it's been working reasonably well so far so I continue to put up with it.

1
  • 1
    Thanks (also for the detailed explanation), that worked like a charm. Doesn't need to be perfect, it's my work PC ;)
    – Max
    Commented Sep 20, 2023 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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