Giter Site home page Giter Site logo

webic / python-syntax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hdima/python-syntax

0.0 0.0 0.0 442 KB

Python syntax highlighting script for Vim

Home Page: http://www.vim.org/scripts/script.php?script_id=790

License: MIT License

Vim Script 90.55% Python 9.45%

python-syntax's Introduction

Python syntax highlighting script for Vim

Enhanced version of the original Python syntax highlighting script. Based on python.vim from Vim 6.1 distribution by Neil Schemenauer (nas at python dot ca). Check also python.vim page on vim.org.

Please use the following channels for reporting bugs, offering suggestions or feedback:

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.

The easiest installation method is to place syntax/python.vim script into your ~/.vim/syntax/ directory.

You can also use Pathogen or Vundle plugin managers in which case you can install the whole python.vim repository into the corresponding plugins directory.

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
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
python_highlight_builtins
Highlight builtin functions and objects
python_highlight_builtin_objs
Highlight builtin objects only
python_highlight_builtin_funcs
Highlight builtin functions only
python_highlight_exceptions
Highlight standard exceptions
python_highlight_string_formatting
Highlight % string formatting
python_highlight_string_format
Highlight syntax of str.format syntax
python_highlight_string_templates
Highlight syntax of string.Template
python_highlight_indent_errors
Highlight indentation errors
python_highlight_space_errors
Highlight trailing spaces
python_highlight_doctests
Highlight doc-tests
python_print_as_function
Highlight print statement as function for Python 2
python_highlight_file_headers_as_comments
Highlight shebang and coding headers as comments
python_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

List of the contributors in alphabetical order:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.