Editing xml files with long lines is really slow in vim. What can I do to fix this?

后端 未结 13 1084
情书的邮戳
情书的邮戳 2021-01-31 02:24

I edit a lot of xml files with vim. The problem is that, because of the long lines, navigation/editing in vim is extremely slow. Is there something I can do (besides turning off

13条回答
  •  误落风尘
    2021-01-31 02:46

    The simplest and most effective solution I have found is to simply disable syntax highlighting:
    syntax off

    This seems to be the culprit when dealing with long lines. Also, from my experience with vim and xml, the size of the file doesn't seem to matter - it's the long lines that cause these slowdowns.

    Another work-around I found useful is to wrap areas with long lines in folds:

      
      A reeealy long line
      
    

    Closing the folds will spare vim from parsing the syntax of those lines. Of course, this approach is not always practical, but it worked very well where I had only a few long lines, or they were in a specific area of the file.

    Often, Vim is still noticeably slower, but in most cases the performance becomes acceptable.

提交回复
热议问题