Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Whenever I'm highlighting code with the minted package, I use \usemintedstyle{vim}, which looks okay aside from the fact that it looks like a dark VIM color scheme applied onto a light background and it makes hard to read on a white background.

Is there any way to change the vim color scheme to match a light background?

Code snippet

share|improve this question

migrated from Nov 21 '11 at 19:35

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 4 down vote accepted

The coloring is done by pygmentize, the command line interface to the Pygments library. The vim style as defined in Pygments is really suited for a dark background, so the 'easy' solution is to either specify a black background or to pick a pre-existing style that's suited for light backgrounds.

If you'd like to specify a new Pygments style, you can do so, but it's a bit complicated. Below I illustrate how to derive a new style ('myvim') from the vim style:

Step 1: Locate your pygments styles subdirectory -- on my machine that's in /usr/local/lib/python2.7/site-packages/pygments/styles

Step 2: In the pygments styles subdirectory create a new file, that contains the following Python code:

from import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
     Number, Operator, Generic, Whitespace, Token

from vim import VimStyle

# inherit basic styles from the VimStyle class in
class MyVimStyle(VimStyle):
    # only change what we need by setting class attributes
    VimStyle.styles[Token] = "#000000"
    VimStyle.styles[Number] = "bold #cd00cd"

Step 3: Open the file and add your new style to the STYLE_MAP dictionary:

#: Maps style names to 'submodule::classname'.
        ... leave other styles definitions alone ...
    'myvim':    'myvim::MyVimStyle', # add this line at the end

Step 4: Compile and to bytcode

$ python
$ python

Step 5: Assuming you did everything correctly, you can test the built in styles plus your new style:



`manni' style on a white background:
char *test = "1000";
int *test_int = (int*) test;
printf("Machine is %s-endian", (test_int >> 1)? "big":"little");    

`vim' style on a dark background:
% note that minted seems to screw up the placment of the background here
char *test = "1000";
int *test_int = (int*) test;
printf("Machine is %s-endian", (test_int >> 1)? "big":"little");  

Derived `myvim' style on a white background:
char *test = "1000";
int *test_int = (int*) test;
printf("Machine is %s-endian", (test_int >> 1)? "big":"little");  


And here's what you should see: Minted new style example

share|improve this answer
Thanks! I wonder why this isn't the default, since documents produced by latex are mostly white (well, articles at least). – Dan Apr 1 '13 at 15:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.