Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Losing syntax on save #15

mauserrifle opened this Issue · 13 comments

8 participants


I'm using the full spf13-vim package, but I think this issue is related to PIV. When I edit most files of projects (old php code with functions only, or a big class file) I lose syntax highlighting after saving. I got a sample code to reproduce the problem:

  1. Open the file go to the end (G). Syntax should be broken already (look at the variable colors)
  2. Go back to the first line (gg) and scroll down to the end using }. Syntax is working!
  3. Save the file (:w). Syntax is broken again

The strange thing is: if i remove something like the first method (get_id) the problem is gone. When I delete the constants, the problem is gone. Not sure how to fix it myself. I assume the highlighter is breaking on some pattern but that is currently out of my league :(

Due to this bug vim is not usable for all my projects as it happens in almost all files. Hope this can be fixed!


Got a temporary fix:

:syn on

That brings back highlighting.

Tried to make a autocmd:

:autocmd BufWriteCmd *.php :syn on

But then the bottom status bar loses style :( Oh well I'm happy I can use :syn on for now.

@mauserrifle mauserrifle reopened this

Hmm I have more problems than this. I got a legacy project with horrible code. 1439 lines within one file. With syn on vim takes like 20 seconds to save the file (yes I've timed it). Vim uses 100% CPU during this 20 seconds. Within other editors like Eclipse PDT there is no slowness.

The syntax highlighter seems to be going wild!

With :syn off the save is instant. I tested this with the default spf13-vim config on three machines.

What have I tried without success:

I can't believe i'm the only one having this issue. The three machines are all debian tho.

With PIV disabled the problem is solved, but no more sweet completion :(


Hi Steve,

I have just tried an Arch Linux LiveCD (, so that is not Debian related. I do not lose the syntax there, but I still have the slow save and 100% CPU on the files i've sent you through e-mail. It even takes 30 seconds because its in virtualbox.

The losing syntax seems Debian related and the slow saving is not Debian related. I think it's one bug, it just acts different on systems.



Hello Steve,

Ok I might have precious information.

Slow saving

I changed php_folding to '0' within ~/.vim/bundle/PIV/ftplugin/php.vim

This is 100% the caus of the 20 sec saving! Saving is instant now!

Changed it back to '1' to find its root cause.

The bug is within line 577 of ~/.vim/bundle/PIV/syntax/php.vim:

 syn region phpFoldFunction matchgroup=Storageclass start="^\z(\s*\)\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function\s\([^};]*$\)\@="rs=e-9 matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldHtmlInside,phpFCKeyword contained transparent fold extend

Removing that line fixes my slow save, the same as completely disabling php_folding.

Currently no idea how to debug this line as I am not really a vim expert.

Losing syntax

Still losing syntax highlighting on saving.

Removing the following within ~/.vim/bundle/PIV/syntax/php.vim:

" Clusters
syn cluster phpClConst contains=phpFunctions,phpClasses,phpIdentifier,phpStatement,phpOperator,phpStringSingle,phpStringDouble,phpBacktick,phpNumber,phpType,phpBoolean,phpStructure,phpMethodsVar,phpConstants,phpException,phpSuperglobals,phpMagicConstants,phpServerVars
syn cluster phpClInside contains=@phpClConst,phpComment,phpParent,phpParentError,phpInclude,phpHereDoc,phpNowDoc
syn cluster phpClFunction contains=@phpClInside,phpDefine,phpParentError,phpStorageClass,phpSpecial
syn cluster phpClTop contains=@phpClFunction,phpFoldFunction,phpFoldClass,phpFoldInterface,phpFoldTry,phpFoldCatch

" Php Region
if exists("php_parent_error_open")
  syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop
  syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop keepend

Gives the same syntax on loading as when I'm done saving (very gray).

Same goes for removing the whole ~/.vim/bundle/ftplugin/php.vim. This way it's lacking colors, but not complete grayness on save.

Hope this might ring a bell!



Same thing under OSX, vim version 7.3.672 compiled using homebrew formula and latest PIV from Vundle.

For now i just removed PIV, will try to fix it this weekend.


Glad I'm not the only one. I haven't looked into it anymore because I gave up on Vim as my primary IDE due to no intellisense autocompletion like i'm used to from Eclipse.

I hope you get the problem fixed. If I need to test things, i'll be happy to!



I think I have kind of the same problem. Not while I'm saving though, but when I'm navigating in any php file : everything becomes gray, and only things like '>' are marked in red... I have to scroll up for a while,n then stop to re-enable the correct syntax highlight.


Ye it happens on different moments. For me it was mainly saving. Haven't touched vim anymore :( I was 'trying' vim when I found out. Surprised the bug is still there. Hope someone finds it. I have no idea where to search (except my finding above this post)


I'm having the same issue. With editing PHP files. Only :syn on helps


For those of you still having issues, you can try using something lighter than PIV. I personally switched to this one myself:

For those looking for a really lightweight alternative, see:

Of course, neither of these options support as much as PIV, but that's part of the reason why they're faster.


Bump! Also meet same issues here.

* Ubuntu 10.10,  
* Vim 7.4 (2013 Aug 10, compiled Oct 17 2013 16:16:48) 

* Do curl -L -o - | sh
* Wait until spf13 successfuly installed.
* Ctrl + P, Open a  pure php class with more than 100 lines 
* Every function within class are folded by default. 
(Color themes shown correctly). 
* Navigate up and down, then editor goes in gray mode.


58 call s:InitVariable("g:load_doxygen_syntax", 1)
59 call s:InitVariable("g:syntax_extra_php", 'doxygen')
60 call s:InitVariable("g:syntax_extra_inc", 'doxygen')

in ~/.spf13-vim-3/.vim/bundle/PIV/ftplugin/php.vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.