Creating files and directories
Vim’s built in file browser, netrw, has a multitude of uses. One oft-overlooked capability is the ability to create files and folders from inside its directory view. Without netrw, I’d need to use:
!mkdir path/to/dir– Make new directories by shelling out:e path/to/dir/file.txt– Open a new buffer at the file path
But netrw gives us a better way and it works from any directory view. I usually open Vim with vim . which pops me right into the netrw view. From here, I can create new files or directories:
%– Create new file from netrwd– Create new directory from netrw
If you’re in a buffer and want to hop back to the file tree, just use :e . and you’ll be placed in a view of the current working directory. From here, you can browse and create a new file or folder exactly where you want it.