flake8.vim


Ⅰ. 插件描述

Ⅱ. 基本信息

创建日期:  2011-09-23
使用用户:  1
Github星:  5
插件作者:  Alex Vidal

Ⅲ. 安装方法

使用Vundle管理器安装

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

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

使用NeoBundle管理器安装

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

使用VimPlug管理器安装

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

使用Pathogen管理器安装

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

Ⅳ. 文档说明

flake8.vim

A Vim plugin that runs your Python source through flake8_ on the fly.

flake8 is a wrapper script around PyFlakes_, pep8_, and codepaths_,
which calculates the McCabe complexity of a block.

This script is heavily inspired by PyFlakes.vim_ by nvie. The actual vim
plugin comes from that version, and is only slightly modified to run
flake8 and correctly parse the results.

Installation

  1. Make sure your .vimrc has the following settings

::

filetype on
filetype plugin on

  1. Copy ftplugin/python/flake8.vim to your ~/.vim/ftplugin/python
    directory, creating it if it doesn't exist.

Usage

  1. Open a Python file
  2. Press <F7> to run flake8 on it

It shows the errors inside a quickfix window, which will allow you to
quickly jump to the error locations by simply pressing [Enter].

Customization

If you don't want to use the <F7> key for flake8 checking, simply
remap it to another key. It autodetects whether it has been remapped and
won't register the <F7> key if so. For example, to remap it to
<F3> instead, use::

autocmd FileType python map <buffer> <F3> :call Flake8()<CR>

Flake8 ignores any file that starts with the header::

# flake8: noqa

You can also selectively ignore any lines by adding a # NOQA comment
to the end.

Tips

A tip might be to run the flake8 check every time you write a Python file,
to enable this, add the following line to your .vimrc file (thanks
Godefroid_)::

autocmd BufWritePost *.py call Flake8()

.. _flake8: http://pypi.python.org/pypi/flake8/
.. _PyFlakes: http://pypi.python.org/pypi/pyflakes/
.. _pep8: http://pypi.python.org/pypi/pep8/
.. _codepaths: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
.. _PyFlakes.vim: http://github.com/nvie/vim-pyflakes
.. _Godefroid: http://github.com/gotcha

添加新评论