How do I browse files more naturally using vim-vinegar's enhanced netrw integration?
Answer
-
Explanation
vim-vinegar is a lightweight plugin by Tim Pope that enhances Vim's built-in file browser (netrw) with a simpler, more intuitive workflow. Its signature feature is the - key, which opens the directory listing for the file you are currently editing — and pressing - again walks up the directory tree.
How it works
-opens netrw in the directory of the current file (not the cwd)- Pressing
-again from netrw moves up one directory level <CR>opens a file or descends into a directory.in netrw pre-populates the command line with the file path under the cursor — handy for:Gblame .or similar commands~in netrw jumps straight to the home directoryy.yanks the absolute path of the file under the cursorItoggles the banner (the header netrw shows at the top of the listing)
vim-vinegar also sets cleaner netrw defaults: it hides dotfiles by default (gh toggles them) and uses a clean list style.
Example
You are editing src/components/Button.jsx. Press - and netrw opens src/components/. Press - again to go up to src/. Navigate to utils/ and press <CR> to enter it.
Tips
- vim-vinegar intentionally avoids NERDTree-style sidebar panels — it treats the file browser as a buffer you jump in and out of
- Install via your plugin manager:
Plug 'tpope/vim-vinegar' - It pairs well with
:set autochdiroff — vinegar handles the directory context per buffer without changing the global cwd - For remote file browsing, netrw (and thus vinegar) also works over SSH:
-on anscp://buffer opens the remote directory