24

I would never have thought that Vim would be so slow. All I have is the following long line:

enter image description here
(Click image to enlarge)

I run Vim (MacVim) under Mac OS X with the terminal app. Here is my vimrc. I hope that it has nothing to do with some of my plugins. If I break up the big line in the image, everything is working fast again.

  • +1. Thanks for the picture! That one line itself is extremely long. Remember that CLI text editors used to limit lines to 255 characters back in the days of DOS. Syntax highlighting requires that each HTML tag open and close be monitored, and each double quote as well, and then each variable. And I'm sure that each time you nest another tag inside the HREF tag, the editor has to figure out just what that means. I've seen emacs have issues highlighting text that VI has no problems with: You too can choose editors on-demand like we do with chrome, FF and the infamous IE browser. – Vlueboy Jun 26 '11 at 8:37
23

This is a known problem with Vim and very long lines. I see three solutions:

  1. Turn off syntax highlighting with :syntax off.
  2. Limit syntax highlighting with :set synmaxcol=200 or some other value.
  3. Break down your long line in smaller chunks with :s/\s<a/<C-v><Enter><a.

In this particular case I'd recommend solution 3.

|improve this answer|||||
36

try following:

" Syntax coloring lines that are too long just slows down the world
set synmaxcol=128

else i recommend speeding up vim by:

set ttyfast " u got a fast terminal
set ttyscroll=3
set lazyredraw " to avoid scrolling problems
|improve this answer|||||
  • 2
    +1. This will be useful, even if it wasn't picked by the asker as "best" answer. – Vlueboy Jun 26 '11 at 8:28
  • 2
    Wow synmaxcol made such a difference when writing blog posts in markdown. – Keith Smiley Aug 9 '13 at 18:00
  • lazyredraw did the trick for me. Even without any plugins scrolling through certain files was excruciatingly slow. This was the case in both vim and gvim. Profiling did not show anything. – Confusion Jun 14 '14 at 14:21
  • set synmaxcol=4096 completely resolved the issue of syntax highlighting being broken on long lines :) – Jay Taylor Sep 18 '16 at 15:43
1

I think you seem to have cursorline set. I found that used to be the biggest contributor to lag in my vim. You might want to try disabling that.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.