Thu, 10 Nov 2016 01:35:08 -0500
auto-mkdir on write
.vimrc | file | annotate | diff | comparison | revisions |
--- a/.vimrc +++ b/.vimrc @@ -360,6 +360,20 @@ augroup vimrc \ endif augroup END +function! s:MkNonExDir(file, buf) + if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/' + let dir=fnamemodify(a:file, ':h') + if !isdirectory(dir) + call mkdir(dir, 'p') + endif + endif +endfunction + +augroup AutoMkdir + autocmd! + autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>')) +augroup END + " https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/ augroup encrypted autocmd!