jpythonfold.vim


Ⅰ. 插件描述

A better python fold script

Ⅱ. 基本信息

创建日期:  2009-02-01
使用用户:  13
Github星:  6
插件作者:  Jurjen Bos

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

This script allows automatically folding of Python code.
It completely rewritten from Jorrit Wiersma's script (vimscript #515; other competitors are vimscript#781 and vimscript#2002).
The folding and fold text are completely rewritten: the algorithm systematically set up, so it behaves as accurate as possible (at the cost of some speed).
Main feature of this script is that it folds empty space, saving lots of screen space (although you can turn it off, see below).
Classes and defs are folded, of course.
Indent zero comments separating classes and defs are not folded, so you see the global divisions in your code.
Global code is folded in blocks (separated by comments).

There are three options. To use them, check the script:

  • Keep empty lines out of a fold (giving more readable classes with folded functions, but using more screen space).
  • Ignore non-python files.
  • Allow for multiline class definitions (at the cost of folding comments starting with the word "class") or stricter def checking (missing multiline defs).

Known bug:

  • multiline strings that look like code are handled as such (basically unfixable, actually)

Example:

unfolded comment

def foo:

folded comment

    #also folded
    bar = 5

unfolded, but the empty line above this one is folded with the function

code below will be folded

a = 5
b = 6

添加新评论