diff --git a/.vim/autoload/vimrc.vim b/.vim/autoload/vimrc.vim new file mode 100644 --- /dev/null +++ b/.vim/autoload/vimrc.vim @@ -0,0 +1,21 @@ + +function! vimrc#AutoFmtToggle() abort + if &formatoptions =~ 'a' + setl fo-=a + echo '-a' + else + setl fo+=a + echo '+a' + endif +endfunction + +" Make paths when writing, as necessary +function! vimrc#MkNonExDir(file, buf) abort + 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 +