Kim Schulz wrote:
hi
Is there an easy way to get only the basename (filename) without the
path when using bufname()??
I am using it for a guitablabel and have tried with
let label = bufname(i-1);
let filename = expand("".label.":h")
but that does not work. so what is the correct way ?
If bufname() gives only the basename, it could be
a) a file in the current directory
b) a buffer with no corresponding disk file.
In case b) there is of course no full path.
In case a) the full path is fnamemodify(bufname(i-1), ':p'). The ":h"
suffix which you used means "strip the filename, leaving only the
containing directory".
See
:help fnamemodify()
:help filename-modifiers
Best regards,
Tony.