" " big_file_options.vim: When opening a large file, take some measures to keep " things loading quickly. " " Author: Tom Ryder " License: Same as Vim itself " if exists('g:loaded_big_file_options') || &compatible finish endif if !has('autocmd') || v:version < 600 finish endif let g:loaded_big_file_options = 1 " Declare function for turning off slow options function! s:BigFileOptions() " Don't do anything if the buffer size is under the threshold let l:size = exists('g:big_file_size') \ ? g:big_file_size \ : 10 * 1024 * 1024 if line2byte(line('$') + 1) <= l:size return endif " Turn off backups, swap files, and undo files setlocal nobackup setlocal nowritebackup setlocal noswapfile if has('persistent_undo') setlocal noundofile endif " Limit the number of columns of syntax highlighting let l:synmaxcol = exists('g:big_file_synmaxcol') \ ? g:big_file_synmaxcol \ : 256 if exists('+synmaxcol') && &l:synmaxcol > l:synmaxcol let &l:synmaxcol = l:synmaxcol endif " Disable syntax highlighting if configured to do so let l:syntax = exists('g:big_file_syntax') \ ? g:big_file_syntax \ : 0 if !l:syntax setlocal syntax=OFF endif endfunction " Define autocmd for calling to check filesize augroup big_file_options autocmd! autocmd BufReadPost * call s:BigFileOptions() augroup end