blob: 962d71533ee2d39a81b1e6593f11bf13cb4350fb (
plain) (
tree)
|
|
"
" bigfile.vim: When opening a large file, take some measures to keep things
" loading quickly.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" Copyright: 2017
" License: Same as Vim itself
"
if has('eval') && has('autocmd')
" Default threshold is 10 MiB
if !exists('g:bigfile_size')
let g:bigfile_size = 10 * 1024 * 1024
endif
" Declare function for turning off slow options
function! s:BigFileMeasures()
let l:file = expand('<afile>')
if getfsize(l:file) > g:bigfile_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 bigfile_options_bufreadpre
autocmd!
autocmd BufReadPre * call s:BigFileMeasures()
augroup end
endif
|