python-syntax


Ⅰ. 插件描述

Python syntax highlighting for Vim

Ⅱ. 基本信息

创建日期:  2013-02-24
使用用户:  413
Github星:  209
插件作者:  Vim Python

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'vim-python/python-syntax-please-everybody'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

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

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'vim-python/python-syntax-please-everybody'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'vim-python/python-syntax-please-everybody'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

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

Ⅳ. 文档说明

Python syntax highlighting for Vim

This is an enhanced version of the original Vim 6.1 Python syntax highlighting
python.vim by Neil Schemenauer.

Features

  • Enhanced highlighting for:

    • Strings
    • Special symbols inside strings
    • Numeric constants
  • Added support for:

    • Python 3
    • Numbers with underscores
    • String %-formatting and f-strings
    • Magic comments: source code encoding and shebangs
    • New exceptions and builtins
    • Doctests
    • @decorator syntax
    • Class variables such as self and cls
    • Operators
  • Highlighting of the following errors:

    • Invalid symbols in source file
    • Invalid numeric constants
    • Invalid %-formatting inside strings
    • Invalid variable names
    • Invalid operators
    • Mixing spaces and tabs
    • Trailing spaces (Enabled with g:python_highlight_space_errors)
  • Commands for easy switching between versions

Folding is done by the plugin SimpylFold.

How to install

Use one of the following plugin managers:

Configuration

Option variables

Set variable to 1 to enable or 0 to disable.

For example to enable all syntax highlighting features you can add the
following command to your ~/.config/nvim/init.vim or ~/.vimrc:

let g:python_highlight_all = 1
VariableDescriptionDefault
g:python_version_2Python 2 mode0
b:python_version_2Python 2 mode (buffer local)0
g:python_highlight_builtinsHighlight builtin functions and objects0
g:python_highlight_builtin_objsHighlight builtin objects only0
g:python_highlight_builtin_typesHighlight builtin types only0
g:python_highlight_builtin_funcsHighlight builtin functions only0
g:python_highlight_builtin_funcs_kwargHighlight builtin functions when used as kwarg1
g:python_highlight_exceptionsHighlight standard exceptions0
g:python_highlight_string_formattingHighlight % string formatting0
g:python_highlight_string_formatHighlight syntax of str.format syntax0
g:python_highlight_string_templatesHighlight syntax of string.Template0
g:python_highlight_indent_errorsHighlight indentation errors0
g:python_highlight_space_errorsHighlight trailing spaces0
g:python_highlight_doctestsHighlight doc-tests0
g:python_highlight_func_callsHighlight functions calls0
g:python_highlight_class_varsHighlight class variables self and cls0
g:python_highlight_operatorsHighlight all operators0
g:python_highlight_allEnable all highlight options above, except for previously set.0
g:python_highlight_file_headers_as_commentsHighlight shebang and coding headers as comments0
g:python_slow_syncDisable for slow machines1

Commands

CommandDescription
Python2SyntaxSwitch to Python 2
Python3SyntaxSwitch to Python 3

添加新评论