0

Here's my netrw settings, I toggle netrw with <F2>.

let g:netrw_banner = 0    
let g:netrw_liststyle = 3    
let g:netrw_browse_split = 4    
let g:netrw_altv = 1    
let g:netrw_winsize = 20    
    
set autochdir    
    
" Toggle Vexplore with <F2>    
function! ToggleVExplorer()    
    if exists("t:expl_buf_num")    
        let expl_win_num = bufwinnr(t:expl_buf_num)    
        let cur_win_num = winnr()    
    
        if expl_win_num != -1    
            while expl_win_num != cur_win_num    
                exec "wincmd w"    
                let cur_win_num = winnr()    
            endwhile    
    
            close    
        endif    
    
        unlet t:expl_buf_num    
    else    
         Vexplore"
         let t:expl_buf_num = bufnr("%")    
    endif    
endfunction    
    
map <F2> :call ToggleVExplorer()<CR> 

This is the first view I open netrw:

enter image description here

Then I do some operations in netrw just like this.

enter image description here

But when toggle happened, the operations I did disappear.

enter image description here

Can anyone who knows about netrw help me solve this problem? I have been confused for two months. SOS!

I hope when I open netrw again, I can see the view when I leave netrw. I know that if I don't close netrw it will not clean my operation when switch to other buffers, but sometimes I have to close it temporarily due to valuable screen space.

  • Instead of closing netrw, I have a map to call a function that identifies the netrw window, then shrinks it to a single column (vertical resize 1). When I expand it back, it has the same state. Not ideal, but gets the job done. – unione Nov 21 '22 at 07:06

0 Answers0