How do I open a persistent file explorer sidebar using Vim's built-in netrw?
Answer
:Lexplore
Explanation
:Lexplore opens Vim's built-in netrw file explorer as a persistent sidebar anchored to the left of the screen. Unlike :Explore which replaces the current buffer, :Lexplore keeps the file tree visible as you open and navigate files — no plugins needed.
How it works
:Lexplore— open (or toggle) a left-side netrw window:Lexplore {dir}— open the explorer starting in a specific directory:Rexplore— return focus to the explorer from an open file- Pressing
<CR>on a file opens it in the adjacent editing window while the sidebar stays open - Running
:Lexploreagain closes the sidebar (toggle behavior)
Example
:Lexplore
A narrow file tree opens on the left. Navigate with j/k, enter directories with <CR>, go up with -, and open files. The sidebar persists across file changes.
Tips
- Control the sidebar width:
let g:netrw_winsize = 25in your vimrc (percentage of screen) - Switch to tree view:
let g:netrw_liststyle = 3for an indented directory tree - Toggle hidden files with
ghinside netrw :Lexplorestores the window so:Rexplorecan always return you to it- For a right-side panel, use
:Rexplore(right explore) or setg:netrw_altv = 1