0

This is simillar to this question , but I'm not using NERDTree , instead netrw for same purpose. I have tried tweaking the script in my .vimrc a little bit , but I have no idea what do netrw buffers are named as.

With NERDTree this went well , but having tough luck with netrw.

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif

Thanks :)

Community
  • 1
  • 1
Abhinav Gauniyal
  • 7,034
  • 7
  • 50
  • 93

1 Answers1

2

Add to your .vimrc file

aug netrw_close
  au!
  au WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&filetype") == "netrw"|q|endif
aug END

Warnings

I did not test the code above.

Netrw can easily be the only open window. This would mean your Vim instance would close unexpectedly. It would be better to learn how to use :qa if you want to close all the windows.

Peter Rincker
  • 43,539
  • 9
  • 74
  • 101