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

How do I make Vim's built-in file explorer display files as a tree rather than a flat list?

Answer

:let g:netrw_liststyle=3

Explanation

Vim ships with a built-in file browser called netrw, opened with :Explore (or :Ex). By default it shows a flat directory listing, but setting netrw_liststyle to 3 switches it to a persistent tree view — similar to NERDTree — without any plugins.

How it works

  • g:netrw_liststyle controls netrw's display mode
  • Style 0 — thin listing (default)
  • Style 1 — long listing (shows file size and date)
  • Style 2 — wide listing (multiple columns)
  • Style 3 — tree listing (nested directory tree)
  • You can also cycle through styles interactively with i inside netrw

Example

Add to your vimrc:

let g:netrw_liststyle = 3

Then open netrw with :Ex or :Explore. The file tree expands as you navigate into directories, letting you browse multiple levels simultaneously.

Tips

  • Press i inside netrw to cycle through all four listing styles without editing your config
  • :Vexplore (:Vex) opens netrw as a vertical split — combine with liststyle=3 for a sidebar feel
  • Set let g:netrw_winsize = 25 to control the width of the netrw split (as a percentage)
  • Set let g:netrw_banner = 0 to hide the help banner at the top for a cleaner view
  • Press - in any buffer to open netrw in the current file's directory

Next

How do I create new files and directories directly inside Vim's built-in file browser without leaving Vim?