# Make the vim minted style use light terminal-like highlighting instead of dark

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?

-

## migrated from stackoverflow.comNov 21 '11 at 19:35

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

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'.
STYLE_MAP = {
... 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:

\documentclass{article}
\usepackage{minted}

\begin{document}

manni' style on a white background:
\usemintedstyle{manni}
\begin{minted}{c}
char *test = "1000";
int *test_int = (int*) test;
printf("Machine is %s-endian", (test_int >> 1)? "big":"little");
\end{minted}

vim' style on a dark background:
\usemintedstyle{vim}
% note that minted seems to screw up the placment of the background here
\begin{minted}[bgcolor=black]{c}
char *test = "1000";
int *test_int = (int*) test;
printf("Machine is %s-endian", (test_int >> 1)? "big":"little");
\end{minted}

Derived myvim' style on a white background:
\usemintedstyle{myvim}
\begin{minted}{c}
char *test = "1000";
int *test_int = (int*) test;
printf("Machine is %s-endian", (test_int >> 1)? "big":"little");
\end{minted}

\end{document}
`

And here's what you should see:

-
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