Say I type


and hit return. In a .cpp file, or a .js file, the cursor would continue adding *s for me.


But in a .php file, the cursor just moves to the next line. It's very annoying because I'm trying to document our API, which completely lacks it at the moment.

Relevant output:


I don't have anything in my vimrc that is specific to PHP. I do have syntastic installed, but for some reason in php files, comment lines aren't even being grayed out as if they were comments.

Any ideas? Is there a way I can find out what file is setting different settings?

  • 5
    See :h format-comments for more information. Jun 28 '16 at 15:31
  • 3
    I'm glad you found the answer! You should self-answer this question.
    – DJMcMayhem
    Jun 28 '16 at 16:08
  • 2
    You should write a self answer, summarising that SO thread. Self-answers are a good measure of the fact that you found a solution to your question yourself
    – grochmal
    Jun 28 '16 at 16:08

According to a very similar thread on StackOverflow:


I did the following:

  1. Checked that filetype plugin on came before filetype indent on in my .vimrc. It did, so that wasn't the cause of the problem.

  2. Added the following line to make vim register comment lines in php files:

    au FileType php setlocal comments=s1:/*,mb:*,ex:*/,://,:#

    au FileType php setlocal formatoptions+=cro

I made mine match the rest of my files' format options, so I set it to tcroq instead.

I'm using Vim 7.4 on ArchLinux.

Oddly, this didn't set the colors of comments to be grayed out like my colorscheme specifies, but it does have the correct indention behavior.

Edit: Last statement was because of missing <?php ?> tags.

  • 1
    Regarding the comment color, are your comments inside de <?php and ?> tags ? In my Vim it only highlights comments inside those tags. Jun 28 '16 at 18:57
  • Ah! you're right. Jun 28 '16 at 19:00

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.