Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vim-python/python-syntax
Python syntax highlighting for Vim
https://github.com/vim-python/python-syntax
highlighting python syntax vim
Last synced: about 2 months ago
JSON representation
Python syntax highlighting for Vim
- Host: GitHub
- URL: https://github.com/vim-python/python-syntax
- Owner: vim-python
- License: mit
- Created: 2017-02-16T16:53:05.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-19T10:01:49.000Z (about 1 year ago)
- Last Synced: 2024-08-01T03:40:52.153Z (4 months ago)
- Topics: highlighting, python, syntax, vim
- Language: Vim script
- Homepage:
- Size: 189 KB
- Stars: 437
- Watchers: 10
- Forks: 84
- Open Issues: 38
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
- stars - vim-python/python-syntax
README
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`, `cls`, and `mcs`
* 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 versionsFolding is done by the plugin [SimpylFold](https://github.com/tmhedberg/SimpylFold).
How to install
--------------Use one of the following plugin managers:
* [dein](https://github.com/Shougo/dein.vim)
* [vim-plug](https://github.com/junegunn/vim-plug)
* [vundle](https://github.com/VundleVim/Vundle.vim)
* [pathogen](https://github.com/tpope/vim-pathogen)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`:
```vim
let g:python_highlight_all = 1
```
| Variable | Description | Default |
| --------------------------------------------- | -------------------------------------------------------------- | ------- |
| `g:python_version_2` | Python 2 mode | `0` |
| `b:python_version_2` | Python 2 mode (buffer local) | `0` |
| `g:python_highlight_builtins` | Highlight builtin objects, types, and functions | `0` |
| `g:python_highlight_builtin_objs` | Highlight builtin objects only | `0` |
| `g:python_highlight_builtin_types` | Highlight builtin types only | `0` |
| `g:python_highlight_builtin_funcs` | Highlight builtin functions only | `0` |
| `g:python_highlight_builtin_funcs_kwarg` | Highlight builtin functions when used as kwarg | `1` |
| `g:python_highlight_exceptions` | Highlight standard exceptions | `0` |
| `g:python_highlight_string_formatting` | Highlight `%` string formatting | `0` |
| `g:python_highlight_string_format` | Highlight syntax of `str.format` syntax | `0` |
| `g:python_highlight_string_templates` | Highlight syntax of `string.Template` | `0` |
| `g:python_highlight_indent_errors` | Highlight indentation errors | `0` |
| `g:python_highlight_space_errors` | Highlight trailing spaces | `0` |
| `g:python_highlight_doctests` | Highlight doc-tests | `0` |
| `g:python_highlight_func_calls` | Highlight functions calls | `0` |
| `g:python_highlight_class_vars` | Highlight class variables `self`, `cls`, and `mcs` | `0` |
| `g:python_highlight_operators` | Highlight all operators | `0` |
| `g:python_highlight_all` | Enable all highlight options above, except for previously set. | `0` |
| `g:python_highlight_file_headers_as_comments` | Highlight shebang and coding headers as comments | `0` |
| `g:python_slow_sync` | Disable for slow machines | `1` |### Commands
| Command | Description |
| --------------- | ------------------ |
| `Python2Syntax` | Switch to Python 2 |
| `Python3Syntax` | Switch to Python 3 |