I have some C++ sources files which are in a few mega-bytes (a few tens thousands lines) to view and edit. The performance looks really bad in Vim. Refersh (<C-l>) or input single char in insert mode take several seconds to complete. I tried :syn off then all previous operations responded immediately. I also tried set maxlines and minlines to just a few hundred lines, but it doesn't help this situation. Syntax highlighting is not required to be accurate, but editing without it looks a little crazy. Any suggestion to fix such performance issue on syntax highlighting with large files in Vim (I am using gVim)?

UPDATE: I profiled one refresh operation with my large CPP file, and there are many lines like below, how to understand such lines and find out the culprit?

0.248213 58529 28680 0.000127 0.000004 IndentLine \%(^\S\+\)\@<=\%9c
  • 2
    The answers to the duplicate question basically focus on slowness related with too many syntax items. The person who asked the question was using EasyTags with tags syntax highlight enabled. I've added another answer regarding vim's slowness when using syntax folding, which might be what is affecting @Thomson.
    – Vitor
    Commented May 19, 2015 at 18:52
  • Now the IndendLine issue is fixed Commented Oct 22, 2017 at 7:01

3 Answers 3


Actually, while this isn't a solution to your specific problem (improving syntax highlighting for massive files), you may want to actually think about refactoring your source code so that you don't have tens of thousands of line in a single file.

This scenario generally has impacts beyond your editor, things like changing one line of code meaning that you have to compile a rather large chunk of it.

You would probably be far better off figuring out how to modularise your code so that each source file is more manageable (both for editing and other purposes).


I suggest you to disable syntax highlighting as default. It will change your mind about your needs of using it and will definilety improve every performance issue you had in vim:

  • insert in large files;
  • autocomplete;
  • startup time;

give it a try!


This is what has worked for me

Basically, anything which is dependent on syntax, or is a "nice to have", try to not do this for large files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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