My question is fairly simple, still I can't find the answer anywhere : In Vim, how can I close Netrw explorer without actually selecting a file? What keystroke should I hit to close the explorer and go back to the currently opened file?
So far, I have to select the currently opened file from within Netrw if I want to get back to it, which happens to be impossible if I haven't saved it yet.
I may add that I RTFM, and do know the :h netrw
command ;)
Many thanks.
Use <c-6>
/<c-^>
to go back to the previous buffer. See :h CTRL-6
.
Pro-tip: use :Rex
to resume exploring. See :h :Rex
Create the below function:
function! s:close_explorer_buffers()
for i in range(1, bufnr('$'))
if getbufvar(i, '&filetype') == "netrw"
silent exe 'bdelete! ' . i
endif
endfor
endfunction
Add mapping:
nnoremap <C-e><C-x> :call <sid>close_explorer_buffers()<cr>
Vim by default, without plugins etc., should treat netrw windows like buffers (without listing it like one (:ls or :buffer). Try:
:bd
:bdelete
or
:bw
:bwipe
Peculiar way Vim did not list the netrw windows as buffer, but close it like one, and went back to former buffer/file.
With v153 of netrw, one may use :Rex to return to the netrw buffer; it will also permit you to return to the file being edited prior to editing a directory. (see http://www.drchip.org/astronaut/vim/index.html#NETRW for the latest netrw).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With