Você pode usar a chamada expand()
. Por exemplo
:echo expand("#2:p")
Imprimir o caminho completo do arquivo no buffer # 2, você pode listar todos os buffers com :ls
Você pode usar outros modificadores e outras palavras-chave (para ver a página completa de informações em :help expand()
)
Aqui está um trecho rápido:
When {expr} starts with '%', '#' or '<', the expansion is done like for the cmdline-special variables with their associated modifiers. Here is a short overview: % current file name # alternate file name #n alternate file name n <cfile> file name under the cursor <afile> autocmd file name <abuf> autocmd buffer number (as a String!) <amatch> autocmd matched name <sfile> sourced script file name <slnum> sourced script file line number <cword> word under the cursor <cWORD> WORD under the cursor <client> the {clientid} of the last received message server2client() Modifiers: :p expand to full path :h head (last path component removed) :t tail (last path component only) :r root (one extension removed) :e extension only Example: :let &tags = expand("%:p:h") . "/tags" Note that when expanding a string that starts with '%', '#' or '<', any following text is ignored. This does NOT work: :let doesntwork = expand("%:h.bak") Use this: