Normally Vim is damn fast and this is one reason why I love it. But today I got an XML file with over 3 million lines and after opening that file I wanted to jump to the end of the file. This took me over 1 minute which is unacceptable. Turning of syntax highlighting fixes this performance issue, but of course I don’t want to disable it.
I found the solution on stack overflow:
http://stackoverflow.com/questions/19030290/syntax-highlighting-causes-terrible-lag-in-vim
The problem was caused by one regex entry of syntax/xml.vim.
The line containing the regex for xmlSyncDT was causing this issue.
" synchronizing " TODO !!! to be improved !!! syn sync match xmlSyncDT grouphere xmlDocType +\_.\(<!DOCTYPE\)\@=+
By commenting this out the performance issue is gone without noticeable
sideeffects. The comment above the line shows already that the developer
of this file is not happy with it. I can live perfectly without this.
Now I can jump to the end of the 3 million line file without any
noticeable delays.
The post on Stackoverflow shows also how to debug such issues:
:syntime on // do something :syntime report
This statistic shows you where in the syntax highlighter the CPU time gets “burned”.
Comments
comments powered by Disqus