(Mac)Vim quite slow when syntax is set to Ruby (Mac)Vim quite slow when syntax is set to Ruby ruby ruby

(Mac)Vim quite slow when syntax is set to Ruby


As avivr said, Vim is sometimes slow to (especially for ins-completion) in large files due to foldmethod=syntax

From :help todo:

  • Slow combination of folding and PHP syntax highlighting. Script to reproduce it. Caused by "syntax sync fromstart" in combination with patch 7.2.274. (Christian Brabandt, 2010 May 27) Generally, folding with 'foldmethod' set to "syntax" is slow. Do profiling to find out why.

The FastFold plugin makes it so folds are only recalculated on save (so you're always using foldmethod=manual -- but the folds are calculated with foldmethod=syntax or whatever you had set before).

This solved the problem for me. Now I can use compl-whole-line completion in my 5000 line C++ file and it's instant and snappy instead of taking minutes and unresponsive.


Ruby syntax file has been known to be slow, it's better to disable 'cursorline', 'cursorcolumn' since they will cause the most effect.

However you should also have a look at Vim slow with ruby syntax highlighting. Something that could potentially also help improve things.


I had this issue, also tried set regexpengine=1 and various other things.To me it seemed like the slowness was more or less severe depending on the size/complexity of file being edited, but it took a while to pinpoint the exact reason.

In my case the culprit was the following setting:

autocmd Filetype ruby setlocal foldmethod=syntax

This setting tells Vim to create folds automatically based on syntax elements (classes, functions, conditionals).I don't think it matters that it was set with an autocmd in this case.I think the problem was that for fairly complex files, the folds were updated during the editing process, causing dramatic slowness for complex files.

Hope this helps someone.