VIM自动插入PHPdoc
有没有办法使用命令或组合键在 VIM 中插入 PHPDoc?
例如,我有一堂课:
class MyClass
{
public function __construct() { }
public function __destruct() { }
/* command here to insert PHP doc */
public function abc() { }
}
我想插入类似的内容:
/**
* method()
*
* description
*
* @access
* @author
* @param type $varname description
* @return type description
* @copyright
* @version
*/
然后我可以手动填写其余内容。谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用轻量级 phpDocumentor 插件 可以非常有效地完成此操作。
编辑 这是一个修改版本,包含更新的版本发展。
编辑 这是 phpDocumentor 插件的版本 2。它比上面两个链接更新。
将插件安装到您的
$VIMFILES/plugin
目录中,并将其添加到您的 .vimrc 中:上面将 phpDocumentor 绑定到插入中的 Ctrlp,正常和视觉模式。将光标放在类、函数或变量定义上,按 Ctrlp,插件将尝试根据定义形成文档块。
示例函数文档块:
示例类文档块
版权、版本、作者等默认包含在类文档块中。您可以修改插件以包含您自己的默认值:
完整抽象类示例:
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/plugin
directory 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:
假设您将模板放置在 ~/templates/phpdoc.php 中。
使用以下缩写,如果您输入
,p
,您将将 phpdoc.php 的内容读入当前文件,
(位于当前行或当前行下方 - 其中之一)。
然后只需将该行添加到您的 .vimrc 文件中,替换
文件路径和
,p
根据您的喜好。Assume you place your template at ~/templates/phpdoc.php.
With the below abbreviation, if you type
,p
, you willread the contents of your phpdoc.php into the current file,
( at or below the current line - one of those ).
Then just add the line to your .vimrc file, replacing the
file-path and
,p
to your liking.我不能具体谈论 PHP,但你有几个选择。您可以使用缩写(可能不适用于特定示例),或者您可以寻找插件。我可以建议 https://github.com/garbas/vim-snipmate (我使用它并且它工作正常)。
I can't speak for PHP specifically but you have a couple of options. You can use abbreviations (maybe not good for the specific example) or you can look for a plugin. I can suggest https://github.com/garbas/vim-snipmate ( I use it and it works fine).