Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I open a file with vim dir/to/my/file.c how can I easily open the directory dir/to/my in vim's filebrowser?

share|improve this question
up vote 59 down vote accepted

Try :Ex[plore]. From :help Ex:

:Explore will open the local-directory browser on the current file's directory (or on directory [dir] if specified). The window will be split only if the file has been modified, otherwise the browsing window will take over that window. Normally the splitting is taken horizontally.

share|improve this answer

I personally prefer the:


command. It does the split window for you, and drops you into the current directory.

:Sex dir/to/my

works too.

share|improve this answer
This is good but the command is so hard to remember. – Gavin Jun 9 '13 at 20:24
You can also use :Vex to open the directory in a vertical split. – Chuan Ma Jun 25 '14 at 16:56
Vex and Sex are beautiful, that's exactly what I'm looking for online, thank you! – Zen Oct 10 '14 at 13:13
And it turns out that Tex was exactly what I was looking for (rather than tabe.) – SpoonMeiser Apr 28 at 13:42

As already mentioned, you can just do ":Explore" and it will open the file explorer for the directory of the current file.

However, if you need to explicitly specify the directory, you can use ctrl+r on the :-command line to read the contents of any register in, and the % register is the current filename, including a path if necessary. So, just do :e ctrl+r% then backspace over the filename, and press enter.

There are other ways to do it, but this is the method I usually use.

share|improve this answer
I know this is way old, but you can also do :e %[tab] which will expand % for you. – Brian Dec 7 '11 at 15:20

You could use:

:e %:h

More info on expansions is here:

share|improve this answer

:e dir/to/my/

:e . opens the directory you initially launched vim from.

Vim browser 'c' sets the working directory.

I'm not sure if there is a way to automatically jump to the directory of the file you are editing.

share|improve this answer

If you edit with the pwd command on unix it will open the current directory you are in.

:e `pwd`

This will not work like you want it if you did a cd while in vim.

share|improve this answer

For opening Windows Explorer showing current file's directory :

:!start explorer /select,%:p

(Source : )

share|improve this answer
:e `dirname %`

dirname expands to the directory in which current file is.

share|improve this answer

You must log in to answer this question.

protected by Nifle Feb 23 '15 at 21:20

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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