SimpylFold


Ⅰ. 插件描述

No-BS Python code folding for Vim

Ⅱ. 基本信息

创建日期:  2011-09-03
使用用户:  2601
Github星:  452
插件作者:  Taylor Hedberg

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

SimpylFold

Because of its reliance on significant whitespace rather than explicit block
delimiters, properly folding Python code can be tricky. The Python syntax
definition that comes bundled with Vim doesn't contain any fold directives at
all, and the simplest workaround is to set foldmethod=indent, which usually
ends up folding a lot more than you really want it to.

There's no shortage of Vim plugins for improved Python folding, but most seem
to suffer from cobbled-together algorithms with bizarre, intractable bugs
in the corner cases. SimpylFold aims to be exactly what its name suggests:
simple, correct folding for Python.

It's nothing more than it needs to be: it properly folds class and
function/method definitions, and leaves your loops and conditional blocks

  1. There's no BS involved: no screwing around with unrelated options
    (which several of the other plugins do), no choice of algorithms to scratch

your head over (there's only one that's correct); it just works, simply.

Installation

Use one of the following plugin managers:

Also strongly recommend using FastFold
due to Vim's folding being extremely slow by default.

Configuration

No configuration is necessary. However, there are a few configurable options.

Option variables

Set variable to 1 to enable or 0 to disable.

For example to enable docstring preview in fold text you can add the
following command to your ~/.config/nvim/init.vim or ~/.vimrc:

let g:SimpylFold_docstring_preview = 1
VariableDescriptionDefault
g:SimpylFold_docstring_previewPreview docstring in fold text0
g:SimpylFold_fold_docstringFold docstrings1
b:SimpylFold_fold_docstringFold docstrings (buffer local)1
g:SimpylFold_fold_importFold imports1
b:SimpylFold_fold_importFold imports (buffer local)1

Commands

There are also a few buffer local commands for fast toggling:

CommandDescription
SimpylFoldDocstringsEnable docstring folding
SimpylFoldDocstrings!Disable docstring folding
SimpylFoldImportsEnable import folding
SimpylFoldImports!Disable import folding

Usage

Use Vim's built-in folding commands to expand and collapse folds.
The most basic commands are zc to close a fold and zo to open one.
See :help fold-commands for full documentation.

Bugs

If you find any bugs, please report them and submit pull requests on GitHub!
Simple is nice, but simple and correct is much better.

Happy hacking!

添加新评论