Is there a way to insert PHPDoc in VIM using a command or key combination?
For example, I have a class:
class MyClass
{
public function __construct() { }
public function __destruct() { }
/* command here to insert PHP doc */
public function abc() { }
}
I would like to insert something like:
/**
* method()
*
* description
*
* @access
* @author
* @param type $varname description
* @return type description
* @copyright
* @version
*/
And then I can full out the rest manually. Thank you
This can be done pretty effectively with the lightweight phpDocumentor plugin.
Edit Here’s a modified version with more recent development.
Edit Here’s version 2 of the phpDocumentor plugin. It is more recent than the above two links.
Install the plugin into your
$VIMFILES/plugindirectory and add this to your .vimrc:The above binds phpDocumentor to Ctrlp in insert, normal, and visual modes. Place your cursor on a class, function, or variable definition, press Ctrlp, and the plugin will attempt to form a doc block based on the definition.
Example function doc block:
Example class doc block
Copyright, version, author, etc are included by default in a class doc block. You can modify the plugin to include your own default values for these:
Full abstract class example: