I'm on MacVim 7.4 (I use the command line version), installed via Homebrew.
Vim is slow when syntax highlighting Ruby code. htop
shows a 80%-100% CPU usage when moving inside a Ruby file in vim.
I found these here on SO:
and tried the proposed solutions. What I did:
set regexpengine=1
: nothing changed. Still very high CPU usage and slow performances.set lazyredraw
: things are better, but the tradeoff is very noticeable (cursor disappearing while moving)autocmd
statements in my .vimrc
and found nothing slow in particular. I tried removing all the plugins but the problem is still there.I tried turning the syntax off and, well, it solves the problem. Also, starting vim with vim -u NONE
and then turning syntax on
solves the problem, so it must be something in my .vimrc
I guess?
Here's a link to my vimrc
.
I may have found the guilty settings. It seems there are two settings that are noticeably slowing down movement in vim:
set relativenumber
set cursorline
Note that both of these settings trigger this behavior even alone.
These settings force vim to redraw quite a lot of stuff on the screen when scrolling holding j
or k
.
I doubt there's a solution here, but I'm very open to anything to speed this up.
Note that relativenumber
and cursorline
trigger this behavior only when used in Ruby files. Every other filetype I tried (with relativenumber
and cursorline
on) scrolls smoothly, no matter how long.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With