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
-opensnetrwshowing the directory of the currently active file- Navigation uses standard Vim motions:
j/kto move,<CR>to open - Pressing
-while already innetrwascends one directory level - Press
-repeatedly to walk up the directory tree %creates a new file;dcreates a directory;Ddeletes 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-vinegaralso setsliststyle as the default, replacing the old tree-style netrw view- If you use
nvim-treeorneo-tree, you may prefer those — butvim-vinegaris zero-config and ships as a single lightweight plugin - Works with both Vim and Neovim
- Combine with
vim-fugitive's:Gstatusfor a fast no-plugin-manager workflow