pyreformat


Ⅰ. 插件描述

A simple python argument formatter

Ⅱ. 基本信息

创建日期:  2017-04-24
使用用户:  1
Github星:  1
插件作者:  Jay Vana

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

# pyreformat

pyreformat is a small script and vim function to convert Python function calls and definitions. It toggles between single and multi-line definitions.

It changes

def foo(a, b='c', **d):

into

def foo(
    a,
    b='c',
    **d,
):

and vice versa, plus the same action on function calls.

Installation

Script:

# Copy the script to your scripts directory
$ cp pyreformat/__main__.py $HOME/bin
$ chmod +x $HOME/bin/pyreformat

For convenient usage in vim, see https://github.com/jsvana/pyreformat.vim.

Usage

In vim, simply press <Leader>q on a function definition or call.

To use this outside of vim:

$ pyreformat -i <filename> <function_line_number>

then look at your beautifully formatted code.

Motivation

I spend way too much time appeasing the 80 character linter and I don't want to do that anymore.

License

MIT

添加新评论