Monday, December 3, 2012

cursorline, cursorcolumn and syntax making vim slow with ruby files

I recently upgraded to fedora 17 and I noticed today that my cursor movement in vim was getting really slow, so started testing and soon discovered that disabling cursorcolumn and cursorline setting fixed the slowdown.
Now the weird part is that this worked fine before. This even works fine when ssh to a machine with a older 7.x version of vim (rhel5). So testing further also revealed that having cursorline/column on and syntax checking off worked also fine. Furthermore I found out that the slowdown only occurs when editing ruby files.
So as soon as I have one of the cursor options on along with syntax on, things really slow down. And my ruby script has only 300 lines. I Tested vim also on a large perl script (5000+ lines) and noticed only a really tiny slowdown (only because I was paying attention, in day to day operation I wouldn't have noticed). So don't know if anybody knows if this is a (recent) bug in the ruby syntax checking or has the ruby syntax checking become that heavy that things are slow? I understand that screen redraws slow things down, but if redraw was the issue here then the perl file would also suffer from the slowdown
Also have found some interesting things other people tried as a slowdown wordkaround here http://briancarper.net/blog/590/cursorcolumn--cursorline-slowdown and here https://gist.github.com/2624765

4 comments:

  1. Hi good post,
    Its necesary use CLI always or Can I use XenCenter to do all steps.

    And my second cuestion is Can I use http://www.freenas.org/? What do you think?

    Thanks Christof

    ReplyDelete
  2. The second link you posted had a great idea. It didn't work for me, but pointed me in the right direction. Here's what worked for me (added to my .vimrc file):

    let g:boostmove=0
    set updatetime=50
    au CursorMoved * call BoostMoveON()
    au CursorMovedI * call BoostMoveON()
    au CursorHold * call BoostMoveOFF()
    au CursorHoldI * call BoostMoveOFF()
    function BoostMoveON()
    if (g:boostmove == 0)
    let g:boostmove=1
    setlocal nocursorline
    endif
    endfunction
    function BoostMoveOFF()
    if g:boostmove==1
    let g:boostmove=0
    setlocal cursorline
    endif
    endfunction

    ReplyDelete
    Replies
    1. Thxs for your reply. I tested it and seems to work indeed nice. I also had cursorcolumn on and that still makes things slow. Anyway, I can can live with cursorcolumn off :-)

      Delete
  3. This comment has been removed by the author.

    ReplyDelete