On 26/05/12 21:31, Britton Kerin wrote:
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.
[...]

I get error E15 when trying to trigger an autocommand for
        echo <afile>
but
        echo expand('<afile>')
(still in an autocommand) gives the desired result.

See :help expand()

and, for the doubled single quotes between single quotes: :help literal-string

IIUC, the reason for the E15 is that <afile> is only expanded in ex-commands at places where a *file name* is expected. The operand expected by :echo is not an (unquoted) filename but an expression.

In your example, the syntax error may prevent the endif clause from being recognised, thus putting the «echo "foo"» inside the never-executed true branch of «if 0».


Best regards,
Tony.
--
Well, see, Joyce, there we were, trapped in the elevator.  Now, I had
my tennis racquet and the goldfish; she was holding the Crisco.  Surely
you can imagine how one thing naturally led to another!

--
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

Reply via email to