How do I create new files and directories directly inside Vim's built-in file browser without leaving Vim?
Answer
% (in netrw)
Explanation
Vim's built-in file explorer netrw (opened with :Explore or :Ex) is more capable than it looks. You can create files, create directories, rename, and delete — all without dropping to a shell or using an external file manager.
How it works
Key netrw file management commands (pressed while inside netrw):
%— create a new file in the current directory (prompts for a name, then opens it for editing)d— create a new directory (prompts for a name)R— rename the file or directory under the cursorD— delete the file or directory under the cursor (prompts for confirmation)-— navigate up to the parent directory
Example
- Open netrw:
:Exor:Explore - Navigate to your target directory
- Press
%and typenewfile.pyto create and open a new Python file - Press
dand typesrcto create a new directory namedsrc - Press
Rover an existing file to rename it
Tips
Don a directory only works if it is empty; use your shell for non-empty directories- Press
ito cycle between listing styles (thin, long, wide, tree) - Set
let g:netrw_banner = 0in yourvimrcto hide the help banner and get more space :Vexploreopens netrw as a vertical split so you can keep it open while editing- All netrw operations work on remote files too (SSH, FTP) when opening
scp://host/path