diff options
Diffstat (limited to 'plugin/write_mkpath.vim')
-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 |