It seems to be a vanilla-vim issue as the same behaviour also appears when I'm in vim -u NONE.

Basically if you open a file, for example vim src/vector.h, and then split it with :bel vsp %:p:h/vector.cpp, the new split buffer will show the name with its full path. Only if I run :cd %:p:h/../ will the buffer display relative path.

How do I fix this behaviour so that it shows relative path correctly? Since I can't just use autocmd to do the :cd thing on bufopen, as not all files' directory are on the same level, so the command might need to be like :cd %:p:h/../../.

  • 1
    Do you mean :vsp[lit]? I’m not aware of an Ex command :vip
    – D. Ben Knoble
    Commented May 19 at 13:17
  • Totally unrelated to the issue, but vector.h, seriously? This is just asking for confusion with the standard library's vector.
    – Friedrich
    Commented May 19 at 15:26
  • You get the full path because you give the full path to Vim. Use a relative path instead.
    – romainl
    Commented May 19 at 16:32

1 Answer 1


When you do:

:vsplit %:p:h/foo.bar

Vim expands %:p:h to the full path of the directory containing the current file. This means that you give Vim the full path of foo.bar, which becomes the name of the associated buffer. In other words, you get exactly what you asked for.

If you prefer your buffers to be named after their relative path, then… use a relative path:

:vsplit %:h/foo.bar

See :help filename-modifiers.

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.