Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netrw modifying directories always complains

Tags:

vim

netrw

Whenever I make a new directory, copy, a file, etc. using netrw's mt mf mc commands (for example), or just d, my vim gets into a state where it will absolutely, by no means (known to me) be exited from.

Even if I try to type q! from the netrw directory view, I get:

E37: No write since last change
E162: No write since last change for buffer 

Literally all I am left with doing is killing my terminal process.

Assuming I can't change the permissions in this environment. What options am I left with? Completely avoiding netrw for managing directories?

And I'm always seeing this kind of thing after editing files:

"NetrwTreeListing 1" [Not edited][readonly]
like image 869
Daniel Thompson Avatar asked Mar 08 '18 04:03

Daniel Thompson


1 Answers

netrw creates and modifies hidden buffers.

A way out of the situation might be

autocmd FileType netrw setlocal bufhidden=delete

That can be placed in ~/.vimrc, then q! will let you out after netrw work.

This is via Tim Pope, https://github.com/tpope/vim-vinegar/issues/13#issuecomment-47133890 but there are other comments in that thread that that setting may not always work. Works here, but that is probably luck, very light newrw usage, and not bumping into some bufhidden on/off edge case yet.

That autocmd setting might delete a hidden modified buffer that means something someday, so take this as unexpert sledge hammer advice, no warranty expressed or implied.

like image 126
Brian Tiffin Avatar answered Nov 03 '22 15:11

Brian Tiffin