2 Add extra explaination
source | link

Maybe this function will help you? I use it in my neovim configuration. With it :bprev works as expected.

ToggleNetrw display netrw explorer in current window (with command :Ntree) on specified directory (or parent directory of current opened file) and cleanup excess buffer to fix unexpected :bprev behaviour.

Second call of ToggleNetrw hide explorer and show previous buffer.

function! ToggleNetrw(...)
  if &filetype ==# 'netrw'
    execute 'Rexplore'
  else
    if a:0 ==# 1
      let path = fnamemodify(expand(a:1), ':p')
    else
      let path = fnamemodify(expand('%'), ':p:h')
    endif
    execute 'Ntree' path
    let excess_buffer = bufnr(path)
    if excess_buffer != -1
      execute 'bdelete' excess_buffer
    endif
  endif
endf
nnoremap <silent> <Leader>ee :call ToggleNetrw()<CR>
nnoremap <silent> <Leader>ec :call ToggleNetrw('.')<CR>
nnoremap <silent> <Leader>eh :call ToggleNetrw($HOME)<CR>

Maybe this function will help you? I use it in my neovim configuration. With it :bprev works as expected.

function! ToggleNetrw(...)
  if &filetype ==# 'netrw'
    execute 'Rexplore'
  else
    if a:0 ==# 1
      let path = fnamemodify(expand(a:1), ':p')
    else
      let path = fnamemodify(expand('%'), ':p:h')
    endif
    execute 'Ntree' path
    let excess_buffer = bufnr(path)
    if excess_buffer != -1
      execute 'bdelete' excess_buffer
    endif
  endif
endf
nnoremap <silent> <Leader>ee :call ToggleNetrw()<CR>
nnoremap <silent> <Leader>ec :call ToggleNetrw('.')<CR>
nnoremap <silent> <Leader>eh :call ToggleNetrw($HOME)<CR>

Maybe this function will help you? I use it in my neovim configuration. With it :bprev works as expected.

ToggleNetrw display netrw explorer in current window (with command :Ntree) on specified directory (or parent directory of current opened file) and cleanup excess buffer to fix unexpected :bprev behaviour.

Second call of ToggleNetrw hide explorer and show previous buffer.

function! ToggleNetrw(...)
  if &filetype ==# 'netrw'
    execute 'Rexplore'
  else
    if a:0 ==# 1
      let path = fnamemodify(expand(a:1), ':p')
    else
      let path = fnamemodify(expand('%'), ':p:h')
    endif
    execute 'Ntree' path
    let excess_buffer = bufnr(path)
    if excess_buffer != -1
      execute 'bdelete' excess_buffer
    endif
  endif
endf
nnoremap <silent> <Leader>ee :call ToggleNetrw()<CR>
nnoremap <silent> <Leader>ec :call ToggleNetrw('.')<CR>
nnoremap <silent> <Leader>eh :call ToggleNetrw($HOME)<CR>
1
source | link

Maybe this function will help you? I use it in my neovim configuration. With it :bprev works as expected.

function! ToggleNetrw(...)
  if &filetype ==# 'netrw'
    execute 'Rexplore'
  else
    if a:0 ==# 1
      let path = fnamemodify(expand(a:1), ':p')
    else
      let path = fnamemodify(expand('%'), ':p:h')
    endif
    execute 'Ntree' path
    let excess_buffer = bufnr(path)
    if excess_buffer != -1
      execute 'bdelete' excess_buffer
    endif
  endif
endf
nnoremap <silent> <Leader>ee :call ToggleNetrw()<CR>
nnoremap <silent> <Leader>ec :call ToggleNetrw('.')<CR>
nnoremap <silent> <Leader>eh :call ToggleNetrw($HOME)<CR>