Elliot Shank wrote:
From what I understand from the help, you should be able to use
<afile> anywhere in an autocmd to get the name of the file being dealt
with. So why does this complain "E121: Undefined variable: afile":
autocmd BufNewFile *.pm echomsg 'Creating ' <afile>
Obviously, I don't understand when this can be used.
A few seconds of experimenting led me to
:au BufNewFile *.pm echomsg 'Creating' expand("<afile>")
which seems to produce the desired result.
Note that if there were a variable named afile, the echomsg command
could accept as argument an expression such as 'Creating' <afile> 'now'
where < would mean less-than and > would mean greater-than. The result
would not be very meaningful -- it would be 0 or 1, figure it out -- but
from a formal-syntax point of view the expression would be legal.
Best regards,
Tony.