A documentação diz:
<afile> When executing autocommands, is replaced with the file name
for a file read or write.
<abuf> When executing autocommands, is replaced with the currently
effective buffer number (for ":r file" and ":so file" it is
the current buffer, the file being read/sourced is not in a
buffer).
<amatch> When executing autocommands, is replaced with the match for
which this autocommand was executed. It differs from
<afile> only when the file name isn't used to match with
(for FileType, Syntax and SpellFileMissing events).
No entanto, se eu tivesse isso autocmd:
autocmd BufNewFile * echo expand('<amatch>') expand('<afile>')
E aberto, digamos .zshrcem /tmp( cd /tmp; vim .zshrc), recebo:
/tmp/.zshrc .zshrc
Eles não são os mesmos. O que está acontecendo?
%é fiel ao que eu realmente digitei. vim ./.zshrccom expand('%')adicionado ao acima autocmdme dá:
/tmp/.zshrc .zshrc ./.zshrc
%, no entanto, é fiel ao que eu realmente mencionei. Mas não tenho certeza se posso confiar %aqui. : /
vim /tmp/.zshrcelas são as mesmas strings. Se seu cwd for, /tmpvocê obterá um caminho absoluto e um caminho relativo e, embora não sejam as mesmas seqüências de caracteres, eles são os mesmos caminhos.
vim .zshrc
expand('<amatch>') == expand('%:p')e expand('<afile>') == expand('%'). O que você acha ? Edit: Acabei de ver sua edição, a expand('<afile>') == expand('%')não se aplica mais
<afile>apenas o nome do arquivo<amatch>e o caminho completo para o arquivo?