TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 stackoverflow.com Nov 21 '11 at 19:35

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

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, myvim.py that contains the following Python code:

from pygments.style 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 vim.py
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 __init__.py 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 __init__.py and myvim.py to bytcode

$ python __init__.py
$ python myvim.py

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.