Incorrect comments set for php in vim

My vim used to automatically continue comments in php. For example:

/* | <- cursor here 

Then pressing Enter gives me:

 /* * | <- cursor here 

and again, gives me:

 /* * * | <- cursor here 

etc...

As far as I understand, this is controlled by the comments and formatoptions . However, whenever I open a php file, comments matters:

s:<!--,m: ,e:-->

I looked at the entire ~ / .vim folder, as well as the $ VIMRUNTIME folder, and I can’t find out where / why this changed and why the comments parameter is set incorrectly.

Here is a link to my .vimrc

http://pastebin.com/f1509ce65

+6
vim php
source share
4 answers

When setting default version 7.3 (patchset 754), I see the same error as in your original post:

 /**<ENTER> 

Expected Result:

 /** * <cursor> 

Actual result:

 /** <cursor> 

The solution consists of two steps:

A modification of my vimrc that takes these two steps into account:

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

Hooray!

+3
source share

Note.

Note that this problem can also occur if you have the indent on and plugin on file types plugin on separate lines in .vimrc:

 filetype indent on filetype plugin on 

This results in processing $VIMRUNTIME/indent/php.vim to $VIMRUNTIME/ftplugin/php.vim .

The indent/php.vim resets 'comments' , but ftplugin/php.vim does not work.


The order of the mess:

indent/php.vim get the source code and comments to install correctly:

 setlocal comments=s1:/*,mb:*,ex:*/,://,:# 

Then ftplugin/php.vim get the source. It returns ftplugin/html.vim :

 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim 

which lead to the processing and configuration of ftplugin/html.vim :

 setlocal commentstring=<!--%s--> setlocal comments=s:<!--,m:\ \ \ \ ,e:--> 

Later in ftplugin/php.vim commentstring there is a reset, but no comments :

 setlocal commentstring=/*%s*/ 

Fix:

 filetype indent plugin on " Or filetype plugin indent on " Or with correct order: filetype plugin on filetype indent on 

PS.

In any case, the plugin must be processed before indentation.

To check the inclusion / processing order, look at :scriptnames .

+3
source share

Found. I had a funky .vim / indent / php.vim file that somehow inflated it.

Deleted, and the functionality I was looking for returned. Thanks tho!

+1
source share

The php.vim file should be in the ftplugin folder in $VIMRUNTIME .

In version 7.2 vim, the comment line is line 74 in this file.

Did you delete or delete this file?

0
source share

All Articles