Reputation: 461
As long lines will slow down Vim when enabled syntax highlighting.
So, can Vim automatically turns off the syntax highlighting when it detects that a file contains a long line?
Upvotes: 1
Views: 999
Reputation: 27822
In addition to Kent's answer:
The 'synmaxcol'
setting can control how long Vim will keep looking for syntax. the default is 3000; I set it to 500 in my vimrc.
The LargeFile plugin can be used to disable syntax highlighting for large files, which is not exactly what you're asking for, but useful nonetheless.
Upvotes: 6
Reputation: 195079
give this a try:
autocmd syntax *
\ let a=0+system("wc -L ".expand("%")."|awk '{printf $1}'") |
\ if a >= XXXX |
\ syntax off |
\ endif
change the XXX to a number, which indicates the very long line.
Upvotes: 3