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

How do I quickly browse the directory of the current file without leaving Vim?

Answer

- (vim-vinegar)

Explanation

The vim-vinegar plugin by Tim Pope enhances Neovim's built-in netrw file browser. With it installed, pressing - in any buffer opens the directory listing for the current file — the same folder you are editing in. Press - again to go up a level. It turns netrw from a clunky tool into a fluid, less-like file browser you can navigate with standard Vim motions.

How it works

  • - opens netrw showing the directory of the currently active file
  • Navigation uses standard Vim motions: j/k to move, <CR> to open
  • Pressing - while already in netrw ascends one directory level
  • Press - repeatedly to walk up the directory tree
  • % creates a new file; d creates a directory; D deletes the file or directory under the cursor
  • ~ jumps to your home directory; . or ! sends the path to the command line

Example

You are editing src/components/Button.tsx:

Press -
→ Opens netrw at src/components/

Press - again
→ Ascends to src/

Press - once more
→ Ascends to project root

Tips

  • vim-vinegar also sets list style as the default, replacing the old tree-style netrw view
  • If you use nvim-tree or neo-tree, you may prefer those — but vim-vinegar is zero-config and ships as a single lightweight plugin
  • Works with both Vim and Neovim
  • Combine with vim-fugitive's :Gstatus for a fast no-plugin-manager workflow

Next

How do I use capture groups in Vim substitutions to rearrange or swap matched text?