vim-vinegar icon indicating copy to clipboard operation
vim-vinegar copied to clipboard

[RO] buffers of netrw don’t get closed

Open kogakure opened this issue 11 years ago • 44 comments

I found a strange behavior in using vim-vinegar. After a while the buffers opened by "-" don’t get closed any more and stick around (so there might be a dozen buffers with netrw trees open). It’s not possible to close them at all. Not with :bd, :q or even :!bd, !q. The only way to exit vim is to kill it or close the tmux window.

I get this error repeated when trying to close such a buffer:

E37: No write since last change (add ! to override)
E162: No write since last change for buffer "app/views/foldername"

This may be a conflict with some other plugins, but deactivating some plugins which handle buffers like Ctrl-P didn’t help.

kogakure avatar Jan 08 '14 10:01 kogakure

Yep, this is one of the most maddening behaviors of netrw. I actually have a hack in my vimrc to kill these buffers, but I haven't settled on whether it causes any side effects in netrw:

https://github.com/justinmk/config/blob/59b064bb9433449d308b7b889922e2d1c77a30c5/.vimrc#L662

To be clear, netrw sometimes leaves its buffers marked as 'readonly' and 'modified'.

justinmk avatar Jan 08 '14 15:01 justinmk

This isn't related to vim-vinegar. I've seen this before installing it.

I've fixed it by removing these 3 lines from my vimrc https://github.com/edkolev/dots/blob/2ade8ec0d427d7d0b087379239f0d893276ec1f9/vimrc#L297-L299

Not sure which one of them was causing the misbahavior

edkolev avatar Jan 08 '14 20:01 edkolev

Well treeview (g:netrw_liststyle=3) has all kinds of problems, but I don't think it is the cause of this issue.

justinmk avatar Jan 08 '14 20:01 justinmk

I get the same thing, but I found that I could use :bd with the buffer id to close the buffer as a workaround. Ideally, I'd be able to just :bd in the buffer to kill it, though.

kejadlen avatar Jan 28 '14 22:01 kejadlen

this still happens to me a lot. anybody come up with a solid workaround?

jgallen23 avatar Mar 28 '14 23:03 jgallen23

Only slightly better is if you have a buffer manager (I user buffergator) you can usually mark buffers for deletion from that popup window. I choose the buffer in the buffergator window, press d, and move on to the next one that needs deleting. Works similar to emacs in that regard.

jrhorn424 avatar Apr 03 '14 20:04 jrhorn424

This workaround seems to help:

function! QuitNetrw()
  for i in range(1, bufnr($))
    if buflisted(i)
      if getbufvar(i, '&filetype') == "netrw"
        silent exe 'bwipeout ' . i
      endif
    endif
  endfor
endfunction

autocmd MyAutoCmd VimLeavePre *  call QuitNetrw()

At least since I added this to vimrc I don't remember to have this problem.

serebrov avatar Apr 04 '14 07:04 serebrov

:qa! works for me to quit vim when it gets into this state. I never had this problem with netrw alone, though, only when I started using vinegar.

dnr avatar Jun 09 '14 22:06 dnr

I'll be glad if someone provide working solution.. Those stuck netrw buffers is freaking me out :(

wedens avatar Jun 25 '14 08:06 wedens

@wedens I've been navigating away from open netrw buffers with <C-o> and closing them with my buffer manager. I use unite to manage buffers, but most buffer managers have d mapped to close the highlighted buffer in the management window. Otherwise, list the buffers with ls and then issue a bdelete $number where $number is the number of the buffer listed in ls output.

jrhorn424 avatar Jun 25 '14 17:06 jrhorn424

There has to be a better way than these convolusions. What about

autocmd FileType netrw setl bufhidden=delete

tpope avatar Jun 25 '14 17:06 tpope

@tpope that didn't work for me. I still get netrw buffers listed (ones with - at the end are netrw):

screen shot 2014-06-27 at 10 01 17 am

jgallen23 avatar Jun 27 '14 17:06 jgallen23

Can you check and make sure 'bufhidden' is getting set? You can also try a value of wipe.

tpope avatar Jun 27 '14 17:06 tpope

bufhidden doesn't appear to be set. Not sure if it's conflicting with other plugins. I know ctrlp tries to do something special with netrw

jgallen23 avatar Jun 27 '14 17:06 jgallen23

On my box, netrw remains hidden to the native vim buffer-lists, but for some reason Unite buffer will display them. Really annoying.

hkjels avatar Sep 19 '14 08:09 hkjels

I recommend ~~filebeagle~~ https://github.com/justinmk/vim-dirvish if you don't use the remote features of netrw.

justinmk avatar Sep 19 '14 15:09 justinmk

Thanks @justinmk going to give that a try because buffers are still not getting closed.

I dug a little deeper and when I manually open up netrw, the buffers don't show up, but if I use vinegar they do.

jgallen23 avatar Nov 01 '14 18:11 jgallen23

This is very annoying. I've tried to find what causes this bug without any luck.

hkjels avatar Jan 20 '15 12:01 hkjels

I just ended up just using netrw without vinegar because this bug was so annoying.

jgallen23 avatar Jan 20 '15 15:01 jgallen23

I switched to filebeagle also (https://github.com/jeetsukumaran/vim-filebeagle). It's just like netrw+vinegar, but faster and without this bug.

dnr avatar Jan 20 '15 20:01 dnr

@dnr I tried filebeagle, but it didn't have a way to create directories or delete files, which is important to me

jgallen23 avatar Jan 20 '15 21:01 jgallen23

Adding this to .vimrc did not work for me:

autocmd FileType netrw setl bufhidden=delete

However, this worked partially for me:

autocmd FileType netrw setl bufhidden=wipe

The first buffer used by NetRW would stick around. But all subsequent NetRW buffers get wiped by this command.

ashwin avatar Feb 02 '15 05:02 ashwin

Both additions should fall flat because netrw resets &bufhidden in ~.vim/autoload/netrw.vim. See http://www.reddit.com/r/vim/comments/2vfb8o/ignore_certain_buffers_from_c6_jumps/coh6wo9

Konfekt avatar Feb 12 '15 11:02 Konfekt

try :set confirm or maybe :set hidden

zhanjh avatar Apr 01 '15 09:04 zhanjh

What ever happened to this? I still seem to have this bug happening.

errinlarsen avatar Jan 28 '16 21:01 errinlarsen

I am still getting this bug as well

gn0rt0n avatar Mar 04 '16 14:03 gn0rt0n

I encountered this most when attempting to close all my currently open buffers with something like :bufdo bd however I just found that you can use :%bd instead and this works even with an open netrw buffer.

bullfight avatar May 24 '16 23:05 bullfight

for me it was treeview. removing g:netrw_liststyle=3 from my vimrc seems to work

urxvtcd avatar May 26 '16 10:05 urxvtcd

I'm having a similar problem; I made a video of the entire process: https://youtu.be/GSEZteQWkW4

It doesn't seem to have anything to do with vinegar or how many buffers I have open; however, when I create a split window and open netrw, that window becomes "locked" in read-only ([RO]) mode. I don't have any netrw or vinegar settings in my .vimrc.

@tpope, sorry to pollute your plugin with this as I know it is a netrw problem and not a Vinegar problem - but any ideas how to fix this?

trevordmiller avatar Jul 19 '16 20:07 trevordmiller

I found that if I have set hidden in my .vimrc or if called before my first netrw - that I get these orphan netrw buffers. If I don't, I can open a file with vim-vinegar / netrw and then set hidden and things work as expected (no orphans).

ericbock avatar Oct 20 '16 18:10 ericbock