Die Dokumentation sagt:
<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).
Wenn ich das hätte autocmd:
autocmd BufNewFile * echo expand('<amatch>') expand('<afile>')
Und geöffnet, sagen wir .zshrcin /tmp( cd /tmp; vim .zshrc), ich bekomme:
/tmp/.zshrc .zshrc
Sie sind nicht gleich. Was ist los?
%ist treu zu dem, was ich tatsächlich getippt habe. vim ./.zshrcmit expand('%')dem oben genannten autocmdgibt mir:
/tmp/.zshrc .zshrc ./.zshrc
%ist jedoch dem treu, was ich tatsächlich erwähnt habe. Aber ich bin mir nicht sicher, ob ich %hier vertrauen kann . : /
vim /tmp/.zshrcsie die gleichen Zeichenfolgen. Wenn Ihr cwd ist, erhalten /tmpSie einen absoluten Pfad und einen relativen Pfad, und obwohl es sich nicht um dieselben Zeichenfolgen handelt, handelt es sich um dieselben Pfade.
vim .zshrc
expand('<amatch>') == expand('%:p')und expand('<afile>') == expand('%'). Was denken Sie ? Edit: expand('<afile>') == expand('%')
<afile>nur der Dateiname und<amatch>der vollständige Pfad für die Datei angegeben werden?