加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

VIM自动插入PHPdoc

发布时间:2020-12-15 19:09:57 所属栏目:安全 来源:网络整理
导读:有没有办法使用命令或组合键在VIM中插入PHPDoc? 例如,我有一个类: class MyClass{ public function __construct() { } public function __destruct() { } /* command here to insert PHP doc */ public function abc() { }} 我想插入一些东西: /*** meth
有没有办法使用命令或组合键在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
*/

然后我可以手动充分休息。谢谢

轻巧的 phpDocumentor plugin可以非常有效地完成。

编辑Here’s a modified version与最近的发展。

编辑Here’s version 2 of the phpDocumentor plugin.比上述两个链接更新。

将插件安装到$ VIMFILES / plugin目录中,并将其添加到.vimrc中:

" PHP documenter script bound to Control-P
autocmd FileType php inoremap <C-p> <ESC>:call PhpDocSingle()<CR>i
autocmd FileType php nnoremap <C-p> :call PhpDocSingle()<CR>
autocmd FileType php vnoremap <C-p> :call PhpDocRange()<CR>

以上将phpDocumentor绑定到插入,正常和可视模式下的Ctrl。将光标放在类,函数或变量定义上,按Ctrl键,插件将根据定义尝试形成一个文档块。

示例功能doc块:

/**
 * testDocBlock 
 * 
 * @param mixed $param1 
 * @param mixed $param2 
 * @static
 * @access public
 * @return boolean
 */
public static function testDocBlock($param1,$param2) {
  // Pressed Ctl-p while cursor was on the function definition line above...
}

示例类doc块

版本,版本,作者等默认包含在一个类doc块中。您可以修改插件以包括您自己的默认值:

/**
 * TestClass  
 * 
 * @package 
 * @version $id$
 * @copyright 
 * @author Michael <me@exmaple.com> 
 * @license 
 */
class TestClass {

}

全抽象类示例:

<?php
/**
 * TestClass 
 * 
 * @abstract
 * @package 
 * @version $id$
 * @copyright 
 * @author Michael <email@example.com>
 * @license 
 */
abstract class TestClass {
  /**
   * publicProp  
   * 
   * @var string
   * @access public
   */
  public $publicProp;
  /**
   * privateProp  
   * 
   * @var string
   * @access private
   */
  private $privateProp;

  /**
   * testDocBlock  
   * 
   * @param string $param1 
   * @param string $param2 
   * @static
   * @access public
   * @return boolean
   */
  public static function testDocBlock($param1,$param2) {
    // code here...
  }
}
?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读