From 3340d6fa529abed84c44acf7edac1e066494cd3f Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sat, 20 Mar 2021 21:56:35 -0500 Subject: [PATCH] Add Make Directories For The Current File as a Vim til --- README.md | 3 ++- vim/make-directories-for-the-current-file.md | 23 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 vim/make-directories-for-the-current-file.md diff --git a/README.md b/README.md index 3cc055b..242826b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1092 TILs and counting..._ +_1093 TILs and counting..._ --- @@ -1171,6 +1171,7 @@ _1092 TILs and counting..._ - [List All Buffers](vim/list-all-buffers.md) - [List Of Plugins](vim/list-of-plugins.md) - [Load A Directory Of Files Into The Buffer List](vim/load-a-directory-of-files-into-the-buffer-list.md) +- [Make Directories For The Current File](vim/make-directories-for-the-current-file.md) - [Marks Across Vim Sessions](vim/marks-across-vim-sessions.md) - [Match The Beginning And End Of Words](vim/match-the-beginning-and-end-of-words.md) - [Moving To A Specific Line](vim/moving-to-a-specific-line.md) diff --git a/vim/make-directories-for-the-current-file.md b/vim/make-directories-for-the-current-file.md new file mode 100644 index 0000000..69ea8ec --- /dev/null +++ b/vim/make-directories-for-the-current-file.md @@ -0,0 +1,23 @@ +# Make Directories For The Current File + +The [`vim-eunuch` plugin](https://github.com/tpope/vim-eunuch) provides Vim +commands that correspond to many common Unix shell commands. One such command +is an equivalent to the `mkdir` command. + +The `mkdir` command creates the given directory if it doesn't already exist. If +multiples levels of new directories are specified, the `-p` flag can be +included to create each successive level. + +The `vim-eunuch` equivalents are `Mkdir` and `Mkdir!`. + +Let's say I'm working within a project that doesn't currently have a `docs` +directory. When I open up a buffer to `docs/setup.md`, before I can write that +new file, I need to create the `docs` directory. Running `:Mkdir` will do that. + +Now let's say I open up a buffer to `src/api/util/base.js`. The `src` directory +already exists, but neither `/api` nor `util/` nested under it exist. Before I +can write the buffer, I need to create both of those directories. `:Mkdir` on +its own won't create these nested directories. Instead I need to reach for the +`-p` equivalent which is `:Mkdir!`. + +See `:h eunuch-:Mkdir` for more details.