Syntax highlighting causes terrible lag in Vim

前端 未结 10 1525
孤独总比滥情好
孤独总比滥情好 2020-12-12 11:20

I love Vim. But its giving me hard times right now.

I use a lot of plugins and during the last 6 months, I\'ve found a lot of awesome ones. But my Vim got really slu

10条回答
  •  抹茶落季
    2020-12-12 12:00

    EDIT: Blogged about how this all works, with screenshots and awesome-sauce.

    https://eduncan911.com/software/fix-slow-scrolling-in-vim-and-neovim.html

    Original answer below...


    :syntime on
    

    move around in your ruby file and then

    :syntime report
    

    It reported the following slowest matching for me, and you can see that there are not even 1 match.

    I disabled rubyPredefinedConstant in ruby.vim file and problem solved. Vim regex engine does not like something in ruby syntax highlight regex. You will have to find the balance between enough syntax highligting and a good performance.

    hope that helps, here is the top 3 slowest syntax highlighting regex for ruby reported on my Mac OS 10.8.5, homebrew Vim 7.4 (console vim)

        TOTAL      COUNT  MATCH   SLOWEST     AVERAGE   NAME               PATTERN
      3.498505   12494  0       0.008359    0.000280  rubyPredefinedConstant \%(\%(\.\@\%(\s*(\)\@!
      2.948513   12494  0       0.006798    0.000236  rubyPredefinedConstant \%(\%(\.\@\%(\s*(\)\@!
      2.438253   12494  0       0.005346    0.000195  rubyPredefinedConstant \%(\%(\.\@\%(\s*(\)\@!
    

    Or you can try vim-ruby as pointed out by Dojosto

提交回复
热议问题