1

On one copy of Vim that I use sometimes, I get errors like this when I start up:

Error detected while processing /home/besham/.vimrc:
line  524:
E749: empty buffer
line  555:
E749: empty buffer
line  578:
E749: empty buffer
Press ENTER or type command to continue

Those three lines in my vimrc are all write commands that occur within functions, like this:

function! GnuplotCompileOpen()
    write    " this is line 524
    exe ":!gnuplot_pdf \"%\" && open \"" . ChangeExt(expand("%"), "pdf") . "\""
endfunction

It seems like Vim is just executing commands it came across as it was reading my functions! Surely this isn’t the case… right? What is going on here?

This is how this version of Vim is compiled. (I have never seen this kind of behavior in any other version.)

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 28 2019 13:59:32)
Included patches: 1-160, 399, 402-403, 1099
Modified by <bugzilla@redhat.com>
Compiled by <bugzilla@redhat.com>
Small version without GUI.  Features included (+) or not (-):
+acl             -farsi           -mouse_sgr       -tag_old_static
-arabic          -file_in_path    -mouse_sysmouse  -tag_any_white
-autocmd         -find_in_path    -mouse_urxvt     -tcl
-balloon_eval    -float           -mouse_xterm     +terminfo
-browse          -folding         +multi_byte      -termresponse
+builtin_terms   -footer          -multi_lang      -textobjects
-byte_offset     +fork()          -mzscheme        -title
-cindent         -gettext         -netbeans_intg   -toolbar
-clientserver    -hangul_input    -path_extra      -user_commands
-clipboard       +iconv           -perl            -vertsplit
-cmdline_compl   -insert_expand   -persistent_undo -virtualedit
+cmdline_hist    +jumplist        -printer         +visual
-cmdline_info    -keymap          -profile         -visualextra
-comments        -langmap         -python          -viminfo
-conceal         -libcall         -python3         -vreplace
-cryptv          -linebreak       -quickfix        +wildignore
-cscope          -lispindent      -reltime         -wildmenu
-cursorbind      -listcmds        -rightleft       +windows
-cursorshape     -localmap        -ruby            +writebackup
-dialog          -lua             -scrollbind      -X11
-diff            -menu            -signs           -xfontset
-digraphs        -mksession       -smartindent     -xim
-dnd             -modify_fname    -sniff           -xsmp
-ebcdic          -mouse           -startuptime     -xterm_clipboard
-emacs_tags      -mouse_dec       -statusline      -xterm_save
-eval            -mouse_gpm       -sun_workshop    -xpm
-ex_extra        -mouse_jsbterm   -syntax
-extra_search    -mouse_netterm   -tag_binary
   system vimrc file: "/etc/virc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/etc"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -Wall -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D__linux__ -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -Wl,-z,relro  -L/usr/local/lib -Wl,--as-needed -o vim        -lm  -lselinux -lncurses -lacl -lattr -ldl
  • wrap the function definition into if 1 ... endif statements to prevent non-eval builds of Vim to execute this. – Christian Brabandt Aug 22 at 9:42
3

Your version of vim was compiled without eval support, and I suspect that it therefore does not support functions. Vim would then ignore the function statement and likely tries to execute the bodies.

From :h eval:

Note: Expression evaluation can be disabled at compile time.  If this has been
done, the features in this document are not available.  See |+eval| and
|no-eval-feature|.

And :h :function takes us to eval.txt, from where I grabbed this heading.


As mentioned by Christian Brabandt in the comments,

wrap the function definition in if 1 ... endif statements to prevent non-eval builds of vim from executing this

  • ironically, this appears undocumented in :h :function... – D. Ben Knoble Aug 22 at 0:30

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.