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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityThe command :bd
(delete current buffer) appears to close an active file explorer without closing Vim, even if the explorer is full-screen.
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.
:Sexplore
is that the file is then opened in the split screen. This is the same with :Texplore
.
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.
: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!
).
Jun 8, 2020 at 20:49
:bd
work, but if you're open NerdTree
, this will close NerdTree
and with :Rex
, everything works perfectly.