The vim docs give me the impression that individual autocommands are
executed independently.  However...

This sequence of autocommands:

     autocmd BufWritePost * if 0 | echo <afile> | endif

     autocmd BufWritePost * echo "foo"

will not cause "foo" to be echoed when a buffer is written.

Reversing the order of the above two autocommands will result in "foo"
being echoed.

The <afile> reference is the part of the first autocommand that must be
present to cause this problem.

Replacing the "if 0" with "if 1" in the above results in an error
message when the autocommand is created.  However, the original
autocommand in which I ran accross this problem works fine with its
<afile> reference:

     " Automatically set executable flag for shebang scripts on save.
     autocmd BufWritePost * if getline(1) =~ '^#!\(/usr\)*/bin/' |
           \ silent !chmod ugo+x <afile> | endif

The executable bit is automatically set as intended for shebang files.
However, when a non-shebang file is saved, then subsequently installed
autocommands aren't executed as in the above example.



My --version output:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jan 30 2011 13:23:34)
Compiled by bkerin@rhino
Big version with GTK2 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_gui +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/dyn -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_interact +xterm_clipboard -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/home/bkerin/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
-pthread -I/home/bkerin/local/include/gtk-2.0
-I/home/bkerin/local/lib/gtk-2.0/include
-I/home/bkerin/local/include/atk-1.0
-I/home/bkerin/local/include/cairo
-I/home/bkerin/local/include/gdk-pixbuf-2.0
-I/home/bkerin/local/include/pango-1.0
-I/home/bkerin/local/include/glib-2.0
-I/home/bkerin/local/lib/glib-2.0/include
-I/home/bkerin/local/include/pixman-1 -I/usr/include/freetype2
-I/usr/include/libpng12     -g -O2 -D_FORTIFY_SOURCE=1
-I/home/bkerin/local/include/ruby-1.9.1
-I/home/bkerin/local/include/ruby-1.9.1/i686-linux -DRUBY_VERSION=19
Linking: gcc -L/home/bkerin/local/lib    -L.  -rdynamic
-Wl,-export-dynamic  -Wl,-E   -L/usr/local/lib -o vim   -pthread
-L/home/bkerin/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
-lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo
-lpng12 -lpango-1.0 -lfreetype -lz -lfontconfig -lgobject-2.0
-lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0   -lXt -lncurses -lselinux
    -Wl,-E  -fstack-protector -L/usr/local/lib
-L/home/bkerin/local/lib/perl5/5.12.3/i686-linux/CORE -lperl -lutil
-lc    -Wl,-R -Wl,/home/bkerin/local/lib -L/home/bkerin/local/lib
-lruby -lrt -lm

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui