Spiffy Foldtext


Ⅰ. 插件描述

A plugin for Vim that makes customizing your foldtext easy, while adding new features.

Ⅱ. 基本信息

创建日期:  2014-04-09
使用用户:  6
Github星:  7
插件作者:  Tim Holt

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

A customizable foldtext function that properly takes into account the actual
width of the displayable area of your windows. You are thus able to
right-justify a portion of it, usually meta-data like line count and fold
level.

At the center of the plugin is a special format string. By customizing its
value, you can create your own custom foldtext in a single line in your vimrc.

This plugin is meant to be drop-in-able without the need to make any
adjustments--with nice default settings that increase the clarity of your
partially folded windows. There are no functions mapped or in need of mapping.

The official repository for this plugin is located on bitbucket, at
https://bitbucket.org/atimholt/spiffy_foldtext , but a skeleton git repository
(containing just numbered releases) is kept on github, at
https://github.com/atimholt/spiffy_foldtext for the sake of plugin managers
that don't support Mercurial, like Vundle.

                               The Format String

The format string is customizable by setting the "SpiffyFoldtext_format"
variable, prepended with "g:" for global scope, "b:" for buffer-local scope,
or "w:" for window-local scope--each scope overriding those listed before it.
The format string contains control triggers and literal text describing how
your folded lines will render. For example, here's the default (more or less):

        if has('multi_byte')
            let g:SpiffyFoldtext_format = "%c{═}  %<%f{═}╡ %4n lines ╞═%l{╤═}"
        else
            let g:SpiffyFoldtext_format = "%c{=}  %<%f{=}| %4n lines |=%l{/=}"
        endif

Or, more simply (I'll take the ascii-only version for the sake of
explanation):

        let g:SpiffyFoldtext_format = "%c{=}  %<%f{=}| %4n lines |=%l{/=}"

The plugin parses this string upon first run, then 'compiles' it to your
foldtext each time vim needs to determine what to display on a line that
represents a folded region. In a display area 70 characters wide, the above
example would make this sample text:

    Some text with a foldmarker {{{                                      
        Some indented text        with a wide whitespace region {{{      
                                                                          
        }}}                                                              
    }}}                                                                  

fold to look like this:

    Some text with a foldmarker {{{                                      
    === Some indented text ====== with a wide whitespace |    3 lines |=/=
    }}}                                                                  

or this:

    Some text with a foldmarker {{{  ======================|    5 lines |=

Here's a sampling of what some of the example translates to. See the plugin's
help (:help spiffy_foldtext) for more information on the rest:

   "%c{=}"

This trigger places the text of the fold region's first line into your

  1. As given here, its indentation and wider whitespace regions will be
  2. with the '=' character. See :help spiffy_foldtext-%c.

   "  "

This inserts two literal spaces.

   "%<"

This represents the split between what will be left-aligned in your foldtext
and what will be right aligned. The leftward angle bracket is meant as a
mnemonic to indicate that, should all the contents of the foldtext be too wide
for the display area, the content to the right of this trigger will overwrite
part of the content to the left. See :help spiffy_foldtext-%<.

   "%f{=}"

If the content of the foldtext doesn't fill up the entire display region, the
foldtext will be filled with '='s at this point, to the amount needed to
right-align the right-align section. See :help spiffy_foldtext-%f{}.

  etc.

添加新评论