Vim - going normal slow on large PHP files with syntax highlighting enabled

When I use Vim 7.3 to edit a large PHP file (2000 lines), if I switch from insert mode to normal mode, there is a delay of about 1-2 seconds.

It's pretty frustrating when I need to make some quick changes.

Smaller files (300 lines) have no lag. Reverse (normal mode for insertion) is also not delayed.

The problem is with the syntax highlighting because if I turn off the syntax highlighting the problem goes away.

:syntax off

      

Some things I've tried to no avail:

  • rotary flexion
  • disable matchparen plugin
  • disable all custom plugins
  • using the "largefile" plugin

Note. Except for this problem of switching insert mode to normal, nothing else due to syntax highlighting changes for me when editing large files. That is, entering text in insert mode is fine, shutdown stops, etc.

This makes me think this is something that can be fixed.

I tested this in gVim and console vim (under cygwin) on Windows XP.

Does anyone know what the problem is?

Or can anyone else reproduce this issue? I have googled but I dont see anyone else with the same problem, which is strange.

UPDATE . I think it could only be related to PHP syntax highlighting. I just tried coffeescript and javascript files with 2000+ lines and had no problem with them.

+3


source to share


3 answers


I haven't seen the question you are describing, but an event InsertLeave

is one place to start looking. Check your color scheme (and any other plugins) to see if there is an autocommand InsertLeave

. On my own system, the "lettuce.vim" color file has several of these; perhaps they are expensive or may even cause some kind of recursive processing (just out loud).



Edit . You can check which autocommands are associated with a given event by executing :au {EventName}

eg. :au InsertLeave

...

+6


source


Try this setting in your .vimrc file.



set ttimeoutlen = 0

+1


source


I had the same problem and came up with a plugin

https://github.com/Konfekt/FastFold

which updates the folds in the currently edited buffer with your preferred foldmethod when saving the buffer, and saves them the same as otherwise (while saving the foldmethod style in manual mode).

+1


source







All Articles