argumentrewrap


Ⅰ. 插件描述

Vim plugin to automatically rewrap argument lists to multiple lines

Ⅱ. 基本信息

创建日期:  2010-12-20
使用用户:  14
Github星:  17
插件作者:  Jakob Westhoff

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

======================

ArgumentRewrap for VIM

About

ArgumentRewrap is a plugin for the VIM__ editor to split arbitrary calls with
multiple arguments into multiple lines.

__ http://vim.org

Examples

Think of a function call like this one::

foo( bar, baz, blub );

Calling ArgumentRewrap on this function will split it into multiple lines with
correct indentation::

foo(
    bar,
    baz,
    blub
);

In a real world scenario you will most likely have to handle more complex
arguments, which might contain comma separated lists themselves::

foo( [1,2,3], {a:"A", b:"B", c:"C"}, bar( some, other, function ) );

ArgumentWrap handles nested elements correctly and only rewraps the top level::

foo(
    [1,2,3],
    {a:"A", b:"B", c:"C"},
    bar( some, other, function )
);

If you want to rewrap nested elements simply select the corresponding line with
the cursor and rerun the ArgumentWrap function::

foo(
    [1,2,3],
    {
        a:"A",
        b:"B",
        c:"C"
    },
    bar(
        some,
        other,
        function
    )
);

The plugin function scans for the first occurrence of an opening parenthesis
"(", "[" and "{" which is followed by a comma. Therefore it is possible to
split entries with parenthesis preceding the actual argument list::

foo["bar"] = someFunction( [1,2,3], arg2, arg3, arg4 );

The first brackets used for array access ["bar"] are ignored, as they do
not contain a comma separated argument list::

foo["bar"] = someFunction(
    [1,2,3],
    arg2,
    arg3,
    arg4
);

Installation

Installing this plugin is realized by simply copying its files into the equally
named folders inside your .vim directory. If you are using Pathogen__ just
copy the folders of this plugin to a directory inside your bundle
directory.

__ https://github.com/tpope/vim-pathogen

Keybinding

To simplify usage, you should bind a key to the
argumentrewrap#RewrapArguments function. As an example::

nnoremap <silent> <leader>s :call argumentrewrap#RewrapArguments()<CR>

would bind to <leader>s.

添加新评论