Automatically creates non-existent parent directories when writing a file.
Pure lua. Single file.
:write /foo/bar/file.txt
.bar
directory doesn't exist.bar
directory will be silently created and the write command will succeed.Use your favorite package manager.
lazy.nvim
require("lazy").setup({
{
"mateuszwieloch/automkdir.nvim",
opts = {},
},
})
vim-plug
call plug#begin()
Plug "mateuszwieloch/automkdir.nvim"
call plug#end()
lua <<< EOF
require "automkdir".setup()
EOF
Here are the default config options for automkdir:
{
---@type string[] Array of regexes to try to match filepaths against.
blacklist = { "oil:.*" },
}
++p
flag to :write
, for example :write ++p /path/to/file.txt
. However, that's still some extra keystrokes that I prefer to avoid.