ReST syntax highlighting for Sage docstrings in VIM

ReST syntax highlighting for Sage docstrings in VIM

15 juin 2011 | Catégories: sage | View Comments

Author: Franco Saliola
Contact: saliola at gmail dot com
Date: 3 December 2010

Sage uses ReST syntax in its (Python) docstrings, but the default Python syntax highlighting in vim treats all docstrings as Python strings. Here is a method (by Franco Saliola) to enable ReST highlighting in the docstrings and highlighting of doctests.

/Files/2011/sage_docstring_highlighting.png

Prerequisites

The usual syntax files python.vim and rst.vim must be in the ~/.vim/syntax folder. You can find those on the web. Here is the rst.vim file made by Nikolai Weibull (latest revision: 2010-01-23).

Configuration

Create the directory:

mkdir -p ~/.vim/after/syntax

Any file in this directory will be loaded after the default syntax files, allowing us modify the default highlighting and add our own customizations.

Copy the file python.vim (which can be found in the same directory as this file) into the directory ~/.vim/after/syntax.

The first few lines of the file python.vim define the default colours for the docstring text, the sage keywords and the sage prompt. You might want to modify these to suit your colour scheme.

References

blog comments powered by Disqus