Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Cannot close buffer of NetRW in Vim

📅 2015-Feb-02 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ buffer, error, filebeagle, netrw, vinegar ⬩ 📚 Archive


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

© 2023 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 Mastodon📧 Email