16

I have been trying to figure out how to exit the file explorer in Vim.

:q works, but it closes Vim as well, not just the file browser.

Am I missing something or is this a bug?

16

The command :bd (delete current buffer) appears to close an active file explorer without closing Vim, even if the explorer is full-screen.

14

This is expected behavior.

If you have an open modified file, :Explore will open a split-screen explorer, and typing :q will return to the opened file. If not, it will open a full-screen explorer, and :q will close vim.

If you want to force the split-screen explorer even when the opened file has not been modified, or if no file has been opened, use :Sexplore instead.

You can also use a tabbed full screen explorer with :Texplore, that probably behaves exactly the way you want. It will open the explorer on a new tab, and typing :q will always close that tab, but not vim.

Please take a look at the Vim documentation about these commands.

  • The problem with using :Sexplore is that the file is then opened in the split screen. This is the same with :Texplore. – icc97 Apr 17 '17 at 21:04
8

In Vim 8 (I haven't tried earlier versions) :Rexplore will work.

In :help :Explore it mentions:

:Rexplore            ... Return to/from Explorer

:Rexplore only actually works when you are in the Explorer.

:Lexplore is also a very nice option, as it will open the vertical explorer, but opening any file from there will open the file in your original window. Then you can close the explore window by typing :Lexplore again. This effectively then works similar to other file explorers like NERDTree or as in editors like Sublime Text. This is different behaviour from :Sexplore / :Vexplore / :Texplore which open the file in the same window as the Explorer.

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.