aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-11-02 23:44:42 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-11-02 23:44:42 +1300
commit1d8f87404e2beaed880cb554f03ed4829b00bd78 (patch)
tree4384121a889f813b80a44e5fe2f174fd24c6bdb6 /vim
parentWhoops, left debugging value in here (diff)
downloaddotfiles-1d8f87404e2beaed880cb554f03ed4829b00bd78.tar.gz
dotfiles-1d8f87404e2beaed880cb554f03ed4829b00bd78.zip
Tidy big file measures into a function
Diffstat (limited to 'vim')
-rw-r--r--vim/vimrc31
1 files changed, 22 insertions, 9 deletions
diff --git a/vim/vimrc b/vim/vimrc
index 7449176b..2b8430d3 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -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