vimtricks.wiki Concise Vim tricks, one at a time.

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/k and press <CR> to open a file or enter a directory
  • Press - to go up to the parent directory
  • Press d to create a new directory
  • Press % to create a new file
  • Press D to delete the file or directory under the cursor
  • Press R to 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 i in netrw to cycle through listing styles: thin, long, wide, and tree view
  • Set let g:netrw_liststyle = 3 in your vimrc for tree view by default
  • Set let g:netrw_banner = 0 to hide the informational banner at the top
  • Set let g:netrw_winsize = 25 to make the explorer split take up 25% of the screen
  • Press gh to toggle showing hidden (dot) files
  • Press s to cycle sort order between name, time, and size
  • Use mf to mark files, then mt to set a target directory and mc to copy or mm to move the marked files
  • :Lexplore opens 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/file opens a remote file directly

Next

How do I edit multiple lines at once using multiple cursors in Vim?