2

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 Feb 4 '17 at 13:42
1

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.

1

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 Mar 12 '17 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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