Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if exists('g:automkdir_loaded')
- finish
- endif
- let g:automkdir_loaded = 1
- 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 BWCCreateDir
- autocmd!
- autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
- augroup END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement