I created a Drawer command to use NetRW as a file drawer with two main uses.

Note: I always use the tree listing mode.

  1. Open the working directory
  2. Find a file to allow viewing/opening its siblings

The commands are below:

" open netrw/Explore (similar to NERDTree)
command! -nargs=? Drawer if winnr("$") == 1 | Vexplore <args>| else | 1 wincmd w | Explore <args> | endif
command! DrawerCwd execute 'Drawer' getcwd()
command! DrawerFind let @/=expand("%:t") | execute 'Drawer' expand("%:p:h") | normal n

The only problem is that NetRW won't open a directory if there is already an upper directory open, and this makes my DrawerFind useles when I already have a NetRw window opened.

Here are some examples:

:Explore /foo/bar/baz  " opens /foo/bar/baz dir

:Explore /foo/bar      " move up to /foo/bar as expected

:Explore /foo/bar/baz  " won't move down to /foo/bar/baz until window is closed

How can make NetRW descend to lower directories when an upper one is already viewed?

  • I suppose you could netrw’s cd equivalent – D. Ben Knoble Jun 25 '20 at 1:59
  • Can you please elaborate? :/ – paulodiovani Jun 28 '20 at 21:53
  • typing cd in a netrw buffer will change vim’s current directory to the one currently being browsed. That said, I don’t have the issue you’re describing when I use :e with a directory—perhaps the explore command handles a bit different – D. Ben Knoble Jun 29 '20 at 1:58
  • Just found that it only happens whe using the tree listing style. Setting let g:netrw_liststyle=3 or typing i until tree style is selected. – paulodiovani Jul 3 '20 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.