diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-30 00:42:27 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-30 00:42:27 +1200 |
commit | 53f1a5c423af025ea02ad3ee92099100994b8cb9 (patch) | |
tree | 86a4882170aeae47d9d8f4bc05e84b0f8337b7ef /plugin | |
download | vim-write-mkpath-53f1a5c423af025ea02ad3ee92099100994b8cb9.tar.gz vim-write-mkpath-53f1a5c423af025ea02ad3ee92099100994b8cb9.zip |
First versionv0.1.0
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/write_mkpath.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/plugin/write_mkpath.vim b/plugin/write_mkpath.vim new file mode 100644 index 0000000..4a47d70 --- /dev/null +++ b/plugin/write_mkpath.vim @@ -0,0 +1,17 @@ +" +" write_mkpath: If :write! is issued for a file that has nonexistent path +" elements, create the full path with mkdir() before saving. +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if exists('loaded_write_mkpath') || &compatible || v:version < 700 + finish +endif + +" Check path to every file before it's saved +augroup write_mkpath + autocmd! + autocmd BufWritePre * + \ call write_mkpath#(expand('<afile>:p:h')) +augroup END |