Links
- Quickstart
- Style Rules
- Tokens
- Convert a Vim colorscheme to a pygments theme
- Use tango.vim
as a template, since "it includes all the known
Token types, unlike most (if not all) of the styles
included in the Pygments distribution."
- github: honza/vim2pygments
py file
- Use
:echo globpath(&rtp, "colors/habiLight-256color.vim")
to get the path of
your colorscheme file.
Sample usage
Highlight a python file and display on the terminal
print pygments.highlight(
open("/Users/chirayu/tmp/differ.py").read(),
pygments.lexers.get_lexer_by_name("python"),
pygments.formatters.get_formatter_by_name("terminal256", style="emacs"))
pprint.pprint(list(pygments.formatters.get_all_formatters()))
pprint.pprint(list(pygments.lexers.get_all_formatters()))
Get a lexer for a specific filename
try:
lexer = pygments.lexers.get_lexer_for_filename("/Users/chirayu/tmp/differ.py")
print "Lexer is", lexer
except ValueError:
print "Couldn't locate a lexer"