Cannot close buffer of NetRW in Vim


Vim has a built-in plugin named NetRW that acts as a file explorer to navigate directories and read-write files. I found that all the buffers used by NetRW to show directory listings would exist even after opening a file from them. This cluttered up my buffer list. Furthermore, while inside NetRW I could not close its buffer by using :q.


This turned out to be a problem created by Vinegar, a plugin that makes using NetRW easier. This problem has been discussed here.

From the many solutions offered, adding this line to .vimrc worked for me:

autocmd FileType netrw setl bufhidden=wipe

Note that this still retains the very first buffer used by NetRW to show file listing. All the NetRW buffers that were created later, do not appear in the buffer list. Not a perfect solution, but I can live with it.

Another solution is to use the FileBeagle plugin instead of NetRW and Vinegar. It works the same as NetRW for viewing and opening files from a directory hierarchy. However, you cannot rename or delete files from it.

Tried with: Vim 7.4 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s