Make netrw really behave like Nerdtree

Around a year ago I wrote a brief post on how to replace the NERDTree plugin for Vim with a couple of settings for netrw and some custom scripting. I dug around in the documentation and found a couple of built-in settings for netrw that made it look and feel relatively close to NERDTree.

First, let’s set netrw to use a tree style listing of our directories:

let g:netrw_liststyle = 3

Then we’ll make it open the file in the previous window to the right of the project drawer:

let g:netrw_browse_split = 4
let g:netrw_altv = 1

We can also set the width of the window. The value is set in percent of the total window width:

let g:netrw_winsize = 25

Also if you’re like me and find the banner with information at the top highly annoying, you can easily disable it:

let g:netrw_banner = 0

If you’ve set custom wildignores netrw can inherit them by doing this:

let g:netrw_list_hide = &wildignore

If you want it to launch right after you’ve entered Vim you could map it to the VimEnter autocommand:

augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :Vexplore
augroup END

…and we’re done!

comments powered by Disqus