python_fold


Ⅰ. 插件描述

Folding expression for python

Ⅱ. 基本信息

创建日期:  2002-12-19
使用用户:  44
Github星:  5
插件作者:  Jorrit Wiersma

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

This script uses the expr fold-method to create folds for python source code.

Folds are created for:

  • Class definitions
  • def function definitions
  • Blocks between {{{, }}} markers (but not yet {{{n, etc.)

The fold level for each fold is equal to the indentation divided by the value of the 'shiftwidth' option, so make sure that 'shiftwidth' is set to the right value for your code.

Class and function folds show a count of the number of lines in the fold and the documentation string when closed (contributed by Max Ischenko).

Caveats:

  • The docstring is not shown when it is enclosed in single quotes (like '''comment'''); use double quotes instead (like """comment""")
  • Newest version relies on a blank line following class or function definition if the next bit of code is not a new class or function definition.  If this doesn't suit your programming style, use the _nonblank version 2.2 (nb).  That version is buggier, however.  Do not install both files.

Bugs:

  • It occasionally inserts a bogus fold at complicated structures like conditionals that are followed by a blank line.  A work-around is to remove the blank line or to replace it with a line containing a comment (a single '#' will do)

添加新评论