How do I browse and manage files using Vim's built-in file explorer?
Answer
:Explore / :Vexplore / :Sexplore
Explanation
Vim ships with netrw, a built-in file explorer that lets you browse directories, open files, create new files, rename, and delete — all without plugins. The :Explore command opens the explorer in the current window, while :Vexplore and :Sexplore open it in a vertical or horizontal split.
How it works
:Explore(or:E) opens netrw in the current window, showing the directory of the current file:Vexplore(or:Ve) opens netrw in a vertical split to the left:Sexplore(or:Se) opens netrw in a horizontal split above- Navigate with
j/kand press<CR>to open a file or enter a directory - Press
-to go up to the parent directory - Press
dto create a new directory - Press
%to create a new file - Press
Dto delete the file or directory under the cursor - Press
Rto rename the file under the cursor
Example
You're editing src/main.go and need to open a file in a sibling directory. Press :Ve<CR> to open a vertical split with the file explorer showing the src/ directory:
" ============================================================
" netrw v171
" Current directory: /project/src/
" ============================================================
../
handlers/
models/
utils/
main.go
config.go
Navigate to handlers/ with j and <CR>, then open auth.go by pressing <CR> on it. The file opens in the split where netrw was.
Tips
- Press
iin netrw to cycle through listing styles: thin, long, wide, and tree view - Set
let g:netrw_liststyle = 3in your vimrc for tree view by default - Set
let g:netrw_banner = 0to hide the informational banner at the top - Set
let g:netrw_winsize = 25to make the explorer split take up 25% of the screen - Press
ghto toggle showing hidden (dot) files - Press
sto cycle sort order between name, time, and size - Use
mfto mark files, thenmtto set a target directory andmcto copy ormmto move the marked files :Lexploreopens a persistent left-side explorer similar to NERDTree or a sidebar file tree — it toggles open and closed- netrw can also browse remote files over SSH:
:e scp://host//path/to/fileopens a remote file directly