tags:

views:

464

answers:

5

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.

+4  A: 

I haven't tried it myself, but the LargeFile plugin seems to be exactly to address the kind of stuff you're looking for.

tomasr
A: 

vim -c 'syntax off' filename.ext

This will switch off highlighting _after_ loading the file.
HS
+1  A: 

vim -u NONE <filename>

This will skip all initializations from configuration files.

Use uppercase U when running gvim.

"-i NONE" does only exclude viminfo from being loaded. If you defined syntax hilighting in there, that would help too.

HS
+7  A: 

Add to your .vimrc:

autocmd BufReadPre * if getfsize(expand("%")) > 10000000 | syntax off | endif

Note that this disables syntax highlighting in ALL buffers; syntax is a global vim thing and cannot be restricted to a single buffer.

Zathrus
using 'syntax clear' instead of 'syntax off' applies to the one buffer only.
Paul Oyster
For some reason I cannot mark this answer as accepted, but it is...
Paul Oyster
A: 

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
Paul Oyster