diff --git a/README.md b/README.md index 3d97784..75f3f11 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Count the Number of Matches](vim/count-the-number-of-matches.md) - [Create A New Directory In netrw](vim/create-a-new-directory-in-netrw.md) - [Create A New File In A New Directory](vim/create-a-new-file-in-a-new-directory.md) +- [Creating Non-Existent Directories](vim/creating-non-existent-directories.md) - [Delete Every Other Line](vim/delete-every-other-line.md) - [Delete Lines That Match A Pattern](vim/delete-lines-that-match-a-pattern.md) - [Deleting Directories Of Files From netrw](vim/deleting-directories-of-files-from-netrw.md) diff --git a/vim/creating-non-existent-directories.md b/vim/creating-non-existent-directories.md new file mode 100644 index 0000000..a69fd69 --- /dev/null +++ b/vim/creating-non-existent-directories.md @@ -0,0 +1,12 @@ +# Creating Non-Existent Directories + +When creating new files from withing vim, using `:e`, you may find yourself +creating that file in a directory that doesn't yet exist. Vim will tell you +as much if you then try to save that file. To get around this, I have often +shelled out with `:!mkdir %:h`. This is a bit awkward to type though. + +The [`vim-eunuch`](https://github.com/tpope/vim-eunuch) plugin comes with a +handy command for this. `:Mkdir` will create the parent directory for the +current buffer. If you're in a situation where multiple levels of the +buffer's directory don't exist, you can use `:Mkdir!` which will invoke +`mkdir` with the `-p` flag.