Search code examples
pythonvimsyntax-highlightingvim-syntax-highlighting

Vim python syntax highlighting hangs for very long lines


I have this python script, in one line I have a 1000 character long string. I have syntax highlighting on, vim hangs on this line. If I change the file extension to c++ than it works. I suspect problems with syntax highlighting plugin is is causing the hang.

Can this be fixed somehow? I'm using vim version 7.4.52


Solution

  • Overly long lines can dramatically slow down Vim's syntax highlighting; usually, this is a fault of the syntax script, and you should inform its author (found in the $VIMRUNTIME/syntax/python.vim script header).

    Vim 7.4 includes the :syntime command, which greatly helps with troubleshooting and finding the problematic regular expression.

    It might help to :set synmaxcol=... to a value lower than the default 3000.