aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/bigfile.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/plugin/bigfile.vim')
-rw-r--r--vim/plugin/bigfile.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/vim/plugin/bigfile.vim b/vim/plugin/bigfile.vim
new file mode 100644
index 00000000..5c68b1a7
--- /dev/null
+++ b/vim/plugin/bigfile.vim
@@ -0,0 +1,28 @@
+" When opening a large file, take some measures to keep things loading quickly
+if has('eval') && has('autocmd')
+
+ " Threshold is 10 MiB
+ let g:big_file_size = 10 * 1024 * 1024
+
+ " Declare function for turning off slow options
+ function! s:BigFileMeasures()
+ let l:file = expand('<afile>')
+ if getfsize(l:file) > g:big_file_size
+ setlocal nobackup
+ setlocal nowritebackup
+ setlocal noswapfile
+ if has('persistent_undo')
+ setlocal noundofile
+ endif
+ if exists('&synmaxcol')
+ setlocal synmaxcol=256
+ endif
+ endif
+ endfunction
+
+ " Define autocmd for calling to check filesize
+ augroup dotfiles_big_file_measures
+ autocmd!
+ autocmd BufReadPre * call s:BigFileMeasures()
+ augroup end
+endif