Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

create directory on write

  • Loading branch information...
commit 6def2a491baf08e99e3d9e8d5a027b6f80b31065 1 parent b93d4d9
@yanick authored
Showing with 14 additions and 0 deletions.
  1. +14 −0 vim/vimrc
View
14 vim/vimrc
@@ -223,3 +223,17 @@ nmap cf :let @"=expand("%")<CR>
" perlprove
au BufRead,BufNewFile *.t set filetype=perl | compiler perlprove
+" allow creation of directories on-the-fly
+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
Please sign in to comment.
Something went wrong with that request. Please try again.