Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: How to remain netrw sidebar window when I open a new tab?

Tags:

vim

I have the following in .vimrc:

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 = 25
augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :Vexplore
augroup END

It gives me a nice explorer sidebar when I launch vim. But the problem is when I open a new tab with :tabnew, it lost the sidebar in the new tab. How can I make :tabnew to have the exact same sidebar? Thanks a lot.

like image 429
Sintaloo Avatar asked Oct 27 '25 11:10

Sintaloo


1 Answers

The corresponding event is :help TabNew; if you add that to VimEnter, you should be good to go:

autocmd VimEnter,TabNew * :Vexplore

Unfortunately, that didn't work for me; it just opened an empty window split. Delaying the creation helps:

autocmd VimEnter * :Vexplore
autocmd TabNew * call feedkeys(":Vexplore\<CR>", 'n')

Note that all these instances will be separate from each other; its contents won't be synchronized.

like image 110
Ingo Karkat Avatar answered Oct 30 '25 09:10

Ingo Karkat