Search code examples
vimcolorsvim-syntax-highlighting

How to avoid syntax-highlighting for large files in vim?


Huge files take forever to load and work with in vim, due to syntax-highlighting.

I'm looking for a way to limit size of highlighted files, such that files larger than (say) 10MB will be colorless.


Solution

  • Adding the following line to _vimrc does the trick, with a bonus: it handles gzipped files, too (which is a common case with huge files):

    autocmd BufWinEnter * if line2byte(line("$") + 1) > 1000000 | syntax clear | endif