How do I automatically close the netrw pane after having executed :Vexplore and opened a file in a new buffer?

760 Views Asked by At

What happens now: When I'm in Vim, and execute the :Vexplore command, a new pane appears where can I browse files using netrw. When I open a file in the netrw pane, it opens in the right pane (so not in the netrw pane) like I configured it using let g:netrw_browse_split = 4.

What I would like to happen: However, I would like the netrw pane to close immediately after the new file is opened in the right pane. Is that possible?

This comment on Reddit mentions the use of an autocommand, but I'm not familiar enough with vim scripts in order to create that unfortunately.

1

There are 1 best solutions below

1
Draco Ater On

Seems to me that opening a file in a new buffer and closing the netrw pane is actually the same as opening a file in a netrw pane. And this is by default.

So make sure you have

let g:netrw_browse_split = 0

in your .vimrc and open netrw using :Ex, which will open netrw in current pane.