How do I rename, move, and delete files by editing the filesystem like a buffer with oil.nvim?
Answer
:Oil
Explanation
oil.nvim reimagines file management by presenting a directory as an ordinary Vim buffer. Every entry is just text, so you rename by editing words, delete by removing lines, and create files by adding them — then :w commits all changes atomically to disk. It is especially powerful because it means every Vim motion, operator, and macro you already know can be used for file management.
How it works
:Oilopens the current file's parent directory as an editable buffer:Oil /path/to/diropens any specific directory- Each line represents a file or subdirectory — edit the name to rename it
- Delete a line with
ddto stage that file for deletion - Add a new line (e.g.,
o+ type a name) to create a new file :wapplies all staged changes: renames, deletions, and creations happen together- Press
<CR>to enter a subdirectory or open a file
Example
After :Oil, the buffer might show:
../
README.md
build.sh
config.json
old_notes.txt
Rename build.sh to deploy.sh using ciw on that word. Delete old_notes.txt with dd. Press :w — oil.nvim applies both changes atomically.
Tips
- The default keybinding
-opens oil in the current file's directory (if configured withrequire('oil').setup()) - Use
g?inside the oil buffer to see all available mappings - oil.nvim supports SSH via
oil-ssh://user@host/pathfor remote file management - Unlike netrw, oil buffers are real Vim buffers so you can yank filenames with
yyor use/to search