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

How do I browse directories as plain text buffers using vim-dirvish?

Answer

:Dirvish {path}

Explanation

vim-dirvish (by Justin M. Keyes) is a minimalist directory viewer for Vim. It opens a directory listing as a plain text buffer — every file path is an ordinary line you can search, filter, yank, and operate on with all your normal Vim tools. No tree widget, no special modes: just text.

How it works

  • :Dirvish — open the directory of the current file
  • :Dirvish {path} — open a specific directory
  • <CR> on a file — open it in the current window
  • <CR> on a directory — enter it (reload the listing)
  • - — go up to the parent directory (same key as vim-vinegar)
  • q — close the dirvish buffer
  • Since the buffer is plain text, you can:
    • /pattern to search for a file
    • dG to delete all lines and show only yanked results
    • !command to shell-filter the listing

Install with: Plug 'justinmk/vim-dirvish'

Example

Open the current file's directory:

:Dirvish

Filter to show only Python files using Vim's built-in tools:

:Dirvish
:g!/\.py$/d

Now only .py files are listed. Press <CR> to open any of them.

Tips

  • :Dirvish integrates with netrw-aware plugins — it replaces netrw for directory browsing while keeping gx, gf, and remote file support
  • Use R to reload the listing if the directory changed on disk
  • The vim-dirvish-git companion plugin adds git status indicators to the listing
  • Unlike NERDTree or nvim-tree, dirvish uses zero special syntax — your existing text motion skills transfer completely
  • :set splitright | vsplit | Dirvish opens a directory panel in a vertical split — a lightweight sidebar alternative

Next

How do I run a search and replace only within a visually selected region?