How do I find out the name of the files in the buffers in vim.Is there any command that returns the name of the file?

  • :ls lists buffers...
    – jasonwryan
    Commented Mar 5, 2015 at 7:30

1 Answer 1


The bufname() command returns the filespec of the passed-in buffer number. To get all buffers (like :ls), you can iterate with for bufNr in range(1, bufnr('$')) ... The returned filespec may be relative to the current directory; you can use fnamemodify() to turn it into an absolute filespec.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .