Exit file explorer in Vim without closing

vim
13,779

Solution 1

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

Solution 2

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.

Solution 3

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.

Solution 4

:bd work, but if you're open NerdTree, this will close NerdTree and with :Rex, everything works perfectly.

Share:
13,779

Related videos on Youtube

Bob Mullins
Author by

Bob Mullins

Updated on September 18, 2022

Comments

  • Bob Mullins
    Bob Mullins over 1 year

    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?

    • altsyset
      altsyset almost 4 years
      :e works for me just fine.
  • Todd Baur
    Todd Baur almost 7 years
    The problem with using :Sexplore is that the file is then opened in the split screen. This is the same with :Texplore.
  • Jean Paul
    Jean Paul almost 4 years
    I tried :Lexplore and it did not work like you said: doing :Lex after having opened the new file does not close the explore windows but a open a new one, and after doing :q several times to close everything I don't go back to the original file even if I made modifications on it (I lose them without the need of doing :q!).