我想执行MyCommand需要访问b:somevar由<afile>. 现在我正在做类似的事情
function F()
let l:a = bufnr(expand("%"))
let l:b = bufnr(expand("<afile>"))
execute "bufdo call G(" . l:b . ")"
execute "buffer " . a
endfunction
function G(d)
let l:a = bufnr(expand("%"))
if l:a == a:d
execute 'MyCommand'
endif
endfunction
autocmd BufDelete *.hs :call F()
因此,F()检查每个加载的缓冲区是否是<afile>. 它有效,但感觉相当疯狂,应该有更好的方法。