phpfolding.vim


Ⅰ. 插件描述

Automatic folding of PHP functions, classes,.. (also folds related PhpDoc)

Ⅱ. 基本信息

创建日期:  2006-07-29
使用用户:  110
Github星:  41
插件作者:  Ray Burgemeestre

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'rayburgemeestre/phpfolding-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'rayburgemeestre/phpfolding-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'rayburgemeestre/phpfolding-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/rayburgemeestre/phpfolding.vim

Ⅳ. 文档说明

Abstract

This is a mirror of http://www.vim.org/scripts/script.php?script_id=1623

This script can fold PHP functions and/or classes, properties with their phpdoc
without manually adding marker style folds ({{{ and }}}).
It will generate the following folds when executed:

<?php
/**
 * This is Foo...
 * @author Foo
 */
class Foo 
{
+-- 11 lines: function foo($bar) ** -------------------------------------------------
+--  8 lines: function bar($bar) ** -------------------------------------------------
+-- 24 lines: function baz($bar) ----------------------------------------------------
}
?>

Based on e.g. functions declared like this:

<?php
/**
* This is fooFunction...
*
* @param mixed $bar
* @access public
* @return void
*/
function fooFunction($bar) 
{
    ...
}
?>

SCREENSHOT

You can view a screenshot here: http://blog.cppse.nl/phpfolding-vim

FEATURES

  • It remembers fold settings. If you add functions and execute the script again,
    your opened folds will not be closed.
  • It will not be confused by brackets in comment blocks or string literals.
  • The folding of class properties with their PhpDoc comments.
  • The folding of all class properties into one fold.
  • Folding the original marker style folds too.
  • An "**" postfixing the fold indicates PhpDoc is inside (configurable).
  • An "**#@+" postfixing the fold indicates PhpDocBlock is inside (configurable).
  • Empty lines postfixing the folds can be configured to be included in the fold.
  • Nested folds are supported (functions inside functions, etc.)
  • Folding private, public, protected class variables + multi-line param.
  • Foloding the class is now an option disabled by default.
  • Now works properly as ftplugin

FUTURE

  • Better 'configurability' as opposed to editting the PHPCustomFolds() function
    and some "Script configuration" global variables.

CONTRIBUTE / GITHUB

It's then easier for me to accept pull requests and upload new version(s) here,
also I cannot put phpfolding.vim in the ftplugin/php directory through the
vim.org interface.

COMPATIBILITY

This script is tested successfully with Vim version >= 6.3 on windows and linux
(With 6.0 it works sometimes, I don't recommend using it in that version)

添加新评论