# HG changeset patch # User Meredith Howard # Date 1483993839 18000 # Node ID 4c2db769baac3292df93e62e6ad1591755eab242 # Parent fbf39fa1349c784cf8efb5eeaf9f096cdd64bf55 Move into autoload 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 + diff --git a/.vimrc b/.vimrc --- a/.vimrc +++ b/.vimrc @@ -143,17 +143,7 @@ map te :Tabularize first_eq map tc :Tabularize first_colon map tm :Tabularize methods -function! AutoFmtToggle() - if &formatoptions =~ 'a' - setl fo-=a - echo '-a' - else - setl fo+=a - echo '+a' - endif -endfunction - -map a :call AutoFmtToggle() +map a :call vimrc#AutoFmtToggle() cabbr Q q cabbr W w @@ -325,18 +315,9 @@ augroup vimrc augroup END " Make paths when writing, as necessary -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(''), +expand('')) + autocmd BufWritePre * :call vimrc#MkNonExDir(expand(''), +expand('')) augroup END " https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/ @@ -565,4 +546,3 @@ else endif endif -