4

I have an html file that I am editing. It includes about 1MB of css and stuff from another site, which is all contained on one minified line, which I've folded:

enter image description here

It also causes any jumps 'around' line 11 to take about 5-10s, and as you can see, all text-highlighting underneath it are skipped.

Other than extracting the minified line into another file (which will eventually be done), is there a way for vim to basically just "ignore" this line, or act such that the line isn't there (i.e., so that doing j doesn't take 5 seconds between lines 10-13).

  • 3
    Syntax highlighting probably what's getting strained the most here...the fact that it gives up before the end of the file is surely an indicator. Does :syntax off help? If so, a possible workaround that's slightly less drastic may be temporarily wrapping the long line in HTML comment though that's not guaranteed to work. May just need to keep all highlighting off for this file if you can live with that. – B Layer May 30 '20 at 8:17
  • Check the help for :h synmaxcol – Christian Brabandt May 30 '20 at 18:14
  • Ah, yes, good one. Presumably that's the mechanism causing it to "give up" now (default value: column 3000). So the choice may come down to lower synmaxcol so you retain the current, partial highlighting but without performance problems or say, "heck with it", and shut highlighting off. Still, I'd try temporarily commenting the line out in the hope that you'd fix performance but have highlighting in the rest of the file (except the long line). – B Layer May 30 '20 at 18:27
  • Actually, if you're lucky lowering synmaxcol may be the optimal choice as the help says the lines following the long line "MAY not be highlighted correctly". – B Layer May 30 '20 at 18:38
  • 1
    @ChristianBrabandt by the way, your csv vim.org/scripts/script.php?script_id=2830 is awesome (and those regexes are insane)! – David542 May 31 '20 at 3:25
1

Since @christian-brabandt said for someone else to post the answer, I'll try to consolidate things and close out the question.

Check the help for :h synmaxcol (@christian-brabandt) -

                                                'synmaxcol' 'smc'
'synmaxcol' 'smc'       number  (default 3000)
                        local to buffer
                        {not available when compiled without the +syntax
                        feature}
        Maximum column in which to search for syntax items.  In long lines the
        text after this column is not highlighted and following lines may not
        be highlighted correctly, because the syntax state is cleared.
        This helps to avoid very slow redrawing for an XML file that is one
        long line.
        Set to zero to remove the limit.

From @b-layer: Ah, yes, good one. Presumably that's the mechanism causing it to "give up" now (default value: column 3000). So the choice may come down to lower synmaxcol so you retain the current, partial highlighting but without performance problems or say, "heck with it", and shut highlighting off. Still, I'd try temporarily commenting the line out in the hope that you'd fix performance but have highlighting in the rest of the file (except the long line).

And lastly, your own answer of :set synmaxcol=45 fixed your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.