This may seem a little nit-picky, but I like using the wildmenu to switch between buffers: I do :b and then hit tab until I get to the file I want. The problem is that sometimes, vim shows the entire file path instead of just the file. So instead of getting something nice like

foo.cpp bar.cpp foobar.cpp

I get:

foo.cpp ~/Documents/programming/projects/my_project/src/bar.cpp foobar.cpp

Which ANNOYS THE HELL out of me. Sometimes it happens, sometimes it doesn't. Deleting the buffer and reopening the file doesn't do anything; I have to restart vim in order for it to go away.

Does anyone know why Vim does this?

EDIT: So, I haven't experienced this problem since I last created this post; however, just now the problem happened again, and I now know the situation in which it manifests. The situation is as follows:

I use the 'quickfix' window for viewing compile errors. When I build my project (via :make) and there are errors, if the files that contain the errors are not currently buffered within vim, then the absolute path of the file is shown in the quickfix window and everywhere else for the rest of the vim session; even if I do :edit foo.cpp after the :make, it will still show the full path for the buffer.

Deleting the buffer and doing another :edit doesn't fix it; Vim shows the full path no matter what. The only remedy is to kill Vim, open a new process, and to open the files containing the errors before calling :make.

Very strange. Any ideas?

  • 1
    Are all of them in same folder?
    – SibiCoder
    Commented Feb 4, 2017 at 13:42
  • I noticed just now that the file's name is ~/blah/something but :pwd outputs /Users/me/blah – maybe some plugin code doesn't 'realize' that they're equivalent? Commented Mar 5, 2021 at 18:52

3 Answers 3


That's not a nitpicky concern. You should expect an editor to behave consistently.

As @Raziman points out, buffer names are relative to the current working directory, unless the associated file is NOT even a descendant of the current working directory. If this is not your problem, read on...

If the associated file is definitely a descendant of the current working directory, then it is still possible to get full path buffer names because it depends on how you open the file. For instance, if your current working directory is ~/Documents/programming/projects/my_project/src, you could open foo.cpp in that directory in one of two ways:

  1. Using its relative path like :edit foo.cpp

    The buffer name will just be foo.cpp

  2. Using its full path like :edit ~/Documents/programming/projects/my_project/src/foo.cpp

    The buffer name will be the full path.

How are you opening your files? Are you using a file browser plugin?

  • please view my edit.
    – Fake Jake
    Commented Mar 12, 2017 at 10:04
  • I just noticed that a files named path is ~/blah/something.whatever but :pwd outputs /Users/me/blah. Maybe that's the culprit, i.e. ~ not matching /Users/me in some code in various plugins (or Vim/Neovim itself)? Commented Mar 5, 2021 at 18:51

The files in the current working folder will be shortened whereas the rest will show the full path. :cd %:p:h in a buffer will change the directory to that of the file, but then every file in other folders will show their full path.


Don't know how to fix this from happening, like Niko said it depends on if the file was opened with a non-relative path.

You can close the file using :bw (:bd won't work) and reopen the file (instead of restarting Vim)

Your specific situation sounds like the path is absolute in the make output (it pretty much always is), so that may be why the file is opened using absolute path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.