diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2014-11-02 23:44:42 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2014-11-02 23:44:42 +1300 |
commit | 1d8f87404e2beaed880cb554f03ed4829b00bd78 (patch) | |
tree | 4384121a889f813b80a44e5fe2f174fd24c6bdb6 /vim/vimrc | |
parent | Whoops, left debugging value in here (diff) | |
download | dotfiles-1d8f87404e2beaed880cb554f03ed4829b00bd78.tar.gz dotfiles-1d8f87404e2beaed880cb554f03ed4829b00bd78.zip |
Tidy big file measures into a function
Diffstat (limited to 'vim/vimrc')
-rw-r--r-- | vim/vimrc | 31 |
1 files changed, 22 insertions, 9 deletions
@@ -560,17 +560,30 @@ if has('autocmd') augroup END endif -" When opening a file greater than 10 megabytes in size, take some measures to -" keep things loading quickly -let g:bigfilesize = 10 * 1024 * 1024 -if has('autocmd') +" When opening a large file, take some measures to keep things loading quickly +if has('eval') && has('autocmd') + + " Threshold is 10 MB in size + let g:bigfilesize = 10 * 1024 * 1024 + + " Declare function for turning off slow options + function! BigFileMeasures() + let file = expand("<afile>") + if getfsize(file) > g:bigfilesize + setlocal nobackup + setlocal nowritebackup + setlocal noswapfile + setlocal noundofile + if exists('&synmaxcol') + setlocal synmaxcol=256 + endif + endif + endfunction + + " Define autocmd for calling to check filesize augroup bigfilesize autocmd! - autocmd BufReadPre * let f=expand("<afile>") - \ | if getfsize(f) > g:bigfilesize - \ | setlocal nobackup nowritebackup noswapfile noundofile - \ | if exists('&synmaxcol') | setlocal synmaxcol=256 | endif - \ | endif + autocmd BufReadPre * call BigFileMeasures() augroup end endif |