delete just left netrw buffer after opening file

597 views
Skip to first unread message

Enno

unread,
May 23, 2014, 4:42:55 AM5/23/14
to vim...@googlegroups.com
Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?

For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.

Enno

unread,
May 23, 2014, 4:46:48 AM5/23/14
to vim...@googlegroups.com
Le vendredi 23 mai 2014 10:42:55 UTC+2, Enno a écrit :
> Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?
>
> For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.

This is, under netrw 1.53b. Another curiosity is that, inside a netrw buffer, the :bprevious is without effect, but :bnext works as expected.

Enno

unread,
May 23, 2014, 4:56:35 AM5/23/14
to vim...@googlegroups.com
Le vendredi 23 mai 2014 10:42:55 UTC+2, Enno a écrit :
> Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?
>
> For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.

Unexpectedly, let g:netrw_liststyle = 2 instead of let g:netrw_liststyle = 3 now closes the netrw buffer when opening a file by <CR>.

Charles Campbell

unread,
May 23, 2014, 9:17:01 AM5/23/14
to vim...@googlegroups.com
Enno wrote:
> Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?
>
> For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.
>
That's the default behavior.

Regards,
Chip Campbell

Charles Campbell

unread,
May 23, 2014, 11:37:39 AM5/23/14
to vim...@googlegroups.com
Hello, Enno:

I'm not seeing any problem with :bp or :bn using netrw. I used both
wide and tree listing styles, as I'm guessing that you typically use
tree style, with netrw v149 and v153c.

Please:

* give a list of all netrw options you're using
* try it with netrw v153c
(http://www.drchip.org/astronaut/vim/index.html#NETRW)
* give a sequence of commands that elicit the misbehavior

Merci,
Chip Campbell

Charles E Campbell

unread,
May 26, 2014, 4:39:02 PM5/26/14
to vim...@googlegroups.com
Please try netrw this way: (simple.netrw is attached)

vim -u simple.netrw some-directory-here

You'll need to hit the "i" key a few times to get your preferred tree
listing.

Regards,
Chip Campbell

simple.netrw

Enno

unread,
Jun 1, 2014, 6:40:20 AM6/1/14
to vim...@googlegroups.com
Am Freitag, 23. Mai 2014 10:42:55 UTC+2 schrieb Enno:
> Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?
>
> For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.

Hello Charles,

Thank you for your responsiveness. Here are my netrw settings:

let g:netrw_banner = 0
let g:netrw_special_syntax = 1
let g:netrw_dirhistmax=100
let g:netrw_winsize=30
let g:netrw_altv = 1
let g:netrw_altfile=1
let g:netrw_preview=1
let g:netrw_chgwin = winnr()
let g:netrw_retmap = 1
let g:netrw_home = $HOME."/.cache"
let g:netrw_liststyle=3

Now that I discovered let g:netrw_liststyle=2, I prefer to keep it this way and everything works fine for the moment, buffer switching and closing netrw on hitting <CR> on a file.

I will check your newest version as soon as it hits the github mirror, and check back.

Merci aussi

Enno

Enno

unread,
Jun 1, 2014, 6:43:21 AM6/1/14
to vim...@googlegroups.com
Am Freitag, 23. Mai 2014 10:42:55 UTC+2 schrieb Enno:
> Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?
>
> For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.

I forgot the additional netrw settings by Vim-Vinegar. The ones just posted are set after these:

let g:netrw_sort_sequence = '[\/]$,*,\%(' . join(map(split(&suffixes, ','), 'escape(v:val, ".*$~")'), '\|') . '\)[*@]\=$'
let s:escape = 'substitute(escape(v:val, ".$~"), "*", ".*", "g")'
let g:netrw_list_hide =
\ join(map(split(&wildignore, ','), '"^".' . s:escape . '. "$"'), ',') . ',^\.\.\=/\=$' .
\ (get(g:, 'netrw_list_hide', '')[-strlen(s:dotfiles)-1:-1] ==# s:dotfiles ? ','.s:dotfiles : '')

Charles E Campbell

unread,
Jun 1, 2014, 2:37:26 PM6/1/14
to vim...@googlegroups.com
Hello, Enno:

I just tried

vim -u enno.vimrc .

, navigated to a file, hit <cr> -- and the netrw browser disappeared
and the selected file appeared in its stead. Thus, the "just left netrw
buffer" was automatically deleted (actually, its still there; if you
try :ls! you should see it, but otherwise :bn :bp et al will ignore
it, etc). I did this with netrw v153g, which you can get from my
website: http://www.drchip.org/astronaut/vim/index.html#NETRW.

I had to comment out the g:netrw_list_hide stuff because s:dotfiles is
not defined.

There were no changes that I made for this; I suspect its a vim-vinegar
thing. Please rename vim-vinegar so that it doesn't get used and see if
the problem you're complaining of disappears too.

Regards,
Chip Campbell

enno.vimrc

Enno

unread,
Jun 22, 2014, 11:58:29 AM6/22/14
to vim...@googlegroups.com
Le vendredi 23 mai 2014 10:42:55 UTC+2, Enno a écrit :
> Can one configure netrw so that when opening a file in netrw the just left netrw buffer is automatically deleted?
>
> For example type :e ., navigate to a file, hit <CR>. Then there is the netrw buffer, created by :e . that we just left, and has done its service. Is there an autocmd to delete it? Naive attempts under Gvim 7.4.282 and Windows 7 64 bit failed.

Hello,

I can confirm that the issue is resolved in the Netrw version from June 11, Thank you!

Enno
Reply all
Reply to author
Forward
0 new messages