6

How can I close the Netrw buffer?

I tried both :bd and :bw and neither work.

  • 1
    It's in its own window/pane? :close? – B Layer Dec 22 '17 at 2:16
6

I've had this problem, when using Vinegar to make netrw easier to use. I found a site that offers one solution here, and more solutions here.

The solution that worked for me, was to add this to my .vimrc:

autocmd FileType netrw setl bufhidden=wipe

For the sake of completeness, other solutions:

@serebrov on Github:

function! QuitNetrw()
  for i in range(1, bufnr($))
    if buflisted(i)
      if getbufvar(i, '&filetype') == "netrw"
        silent exe 'bwipeout ' . i
      endif
    endif
  endfor
endfunction

autocmd MyAutoCmd VimLeavePre *  call QuitNetrw()

@slashfoo on Github:

" Remove 'set hidden'
set nohidden

augroup netrw_buf_hidden_fix
    autocmd!

    " Set all non-netrw buffers to bufhidden=hide
    autocmd BufWinEnter *
                \  if &ft != 'netrw'
                \|     set bufhidden=hide
                \| endif

augroup end

The first solution was posted by @tpope, also on github.

3

The autocmd FileType netrw setl bufhidden=wipe still leaves one buffer open. I found this solution, which closes it after opening the file:

let g:netrw_fastbrowse = 0

over at the discussion on https://github.com/tpope/vim-vinegar/issues/13

0

typing q while in the buffer closes mine.

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.