Ⅰ. 插件描述
Python syntax highlighting script for VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'hdima/python-vim-red'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'hdima/python-vim-red'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'hdima/python-vim-red'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/hdima/python-syntax
Ⅳ. 文档说明
Python syntax highlighting script for Vim
.. contents::
About
Enhanced version of the original Python syntax highlighting script. Based onpython.vim
from Vim 6.1 distribution by Neil Schemenauer (nas at python dot
ca). Check also `python.vim page on vim.org
http://www.vim.org/scripts/script.php?script_id=790`_.
Please use the following channels for reporting bugs, offering suggestions or
feedback:
- python.vim issue tracker: https://github.com/hdima/python-syntax/issues
- Email: Dmitry Vasiliev (dima at hlabs.org)
- Send a message or follow me for updates on Twitter: `@hdima
https://twitter.com/hdima`__
Features
Changes from the original python.vim
are:
- Added support for Python 3 syntax highlighting
- Added
:Python2Syntax
and:Python3Syntax
commands which allow to
switch between Python 2 and Python 3 syntaxes respectively without
reloads/restarts
- Updated strings highlighting
- Enhanced special symbols highlighting inside strings
- Enhanced highlighting of numeric constants
- Added optional highlighting for %-formatting inside strings
- Added highlighting for magic comments: source code encoding and #!
(executable) strings - Added highlighting for new exceptions and builtins
- Added highlighting for doctests
- Added highlighting for new
@decorator
syntax introduced in Python 2.4a2 Added highlighting for the following errors:
- invalid symbols in source file
- mixing spaces and tabs
- invalid numeric constants
- invalid %-formatting inside strings
- invalid variable names
- trailing spaces (triggered by the
python_highlight_space_errors
option)
Some of these features was later backported into the original python.vim
.
How to install
The easiest installation method is to place `syntax/python.vim
https://github.com/hdima/python-syntax/blob/master/syntax/python.vim`_ script
into your ~/.vim/syntax/
directory.
You can also use Pathogen <https://github.com/tpope/vim-pathogen>
_ or `Vundle
https://github.com/gmarik/vundle`_ plugin managers in which case you can
install the whole `python.vim repository
https://github.com/hdima/python-syntax`_ into the corresponding plugins
directory.
Script options
There are two commands to enable or disable an option:
:let OPTION_NAME = 1
Enable option:let OPTION_NAME = 0
Disable option
For example to enable all syntax highlighting features you can place the
following command in your ~/.vimrc
script::
let python_highlight_all = 1
Option and commands to select Python version
``python_version_2``
Enable highlighting for Python 2 (Python 3 highlighting is enabled by
default). Also can be set as a local to buffer ``b:python_version_2``
variable.
The following local to buffer commands can be used to switch between two
highlighting modes:
``:Python2Syntax``
Switch to Python 2 highlighting mode
``:Python3Syntax``
Switch to Python 3 highlighting mode
Options used by the script
python_highlight_builtins
Highlight builtin functions and objectspython_highlight_builtin_objs
Highlight builtin objects onlypython_highlight_builtin_funcs
Highlight builtin functions onlypython_highlight_exceptions
Highlight standard exceptionspython_highlight_string_formatting
Highlight %
string formattingpython_highlight_string_format
Highlight syntax of str.format
syntaxpython_highlight_string_templates
Highlight syntax of string.Template
python_highlight_indent_errors
Highlight indentation errorspython_highlight_space_errors
Highlight trailing spacespython_highlight_doctests
Highlight doc-testspython_print_as_function
Highlight print
statement as function for Python 2python_highlight_file_headers_as_comments
Highlight shebang and coding headers as commentspython_highlight_all
Enable all the options above. *NOTE: This option don't override any
previously set options*python_slow_sync
Can be set to 0 for slow machines
Contributors
List of the contributors in alphabetical order:
Andrea Riciputi <https://github.com/mrrech>
_- Anton Butanaev
Antony Lee <https://github.com/anntzer>
_- Caleb Adamantine
David Briscoe <https://github.com/idbrii>
_Elizabeth Myers <https://github.com/Elizafox>
_Ihor Gorobets <https://github.com/iho>
_Jeroen Ruigrok van der Werven <https://github.com/ashemedai>
_John Eikenberry <https://github.com/eikenb>
_Joongi Kim <https://github.com/achimnol>
_Marc Weber <https://github.com/MarcWeber>
_Pedro Algarvio <https://github.com/s0undt3ch>
_Victor Salgado <https://github.com/mcsalgado>
_Will Gray <https://github.com/graywh>
_Yuri Habrusiev <https://github.com/yuriihabrusiev>
_