<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Indelible Ink</title>
 <subtitle>Fresh Ink (Vim)</subtitle>
 <link href="https://www.indelible.org/feeds/ink/vim.xml" rel="self"/>
 <link href="https://www.indelible.org/ink/" rel="alternate"/>
 <updated>2026-04-08T08:42:23+00:00</updated>
 <id>https://www.indelible.org/ink/</id>
 <author><name>Jon Parise</name></author>
 <rights>Copyright 1999-2026 by Jon Parise. All rights reserved.</rights>

 

 
 <entry>
   <title>Vim Color Schemes</title>
   <link href="https://www.indelible.org/ink/vim-colorschemes/"/>
   <updated>2009-04-21T00:00:00+00:00</updated>
   <id>https://www.indelible.org/ink/vim-colorschemes</id>
   <author><name>Jon Parise</name></author>
   <category term="vim" />
   <content type="html">&lt;p&gt;The &lt;a href=&quot;http://www.vim.org/&quot;&gt;Vim&lt;/a&gt; text editor supports highly-configurable color schemes which build
upon the editor’s rich syntax highlighting system.  The stock Vim distribution
includes a number of color schemes, and many more are available from the &lt;a href=&quot;http://www.vim.org/scripts/script_search_results.php?keywords=&amp;amp;script_type=color+scheme&amp;amp;order_by=rating&amp;amp;direction=descending&amp;amp;search=search&quot;&gt;Vim
Scripts repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Color scheme definitions are simply normal Vim scripts that live in the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;colors/&lt;/code&gt; directory of the Vim runtime hierarchy (see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:help runtimepath&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Color schemes are loaded using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:colorscheme&lt;/code&gt; command.  The scheme’s name
is determined by the filename of its script file (minus the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vim&lt;/code&gt; extension).
For example, to load the stock &lt;em&gt;blue&lt;/em&gt; color scheme (which is defined by the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;colors/blue.vim&lt;/code&gt; script):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;colorscheme&lt;/span&gt; blue&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;creating-color-schemes&quot;&gt;Creating Color Schemes&lt;/h2&gt;

&lt;p&gt;Creating a custom color scheme is quite easy.  Start by creating a new Vim
script file in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;colors/&lt;/code&gt; directory based on the name of the new scheme.
Start the script with the following commands:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dark&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&quot;or background=light&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; clear
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;syntax_on&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;syntax&lt;/span&gt; reset
&lt;span class=&quot;k&quot;&gt;endif&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;g:colors_name&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;example&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;These commands will reset the syntax highlighting system to its default state.
Note that some color scheme scripts might prefer a light background, so that
first line should be changed accordingly.  (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;highlight clear&lt;/code&gt; uses the
&lt;em&gt;background&lt;/em&gt; value, so &lt;em&gt;background&lt;/em&gt; must be set first.)&lt;/p&gt;

&lt;p&gt;The final line sets the global &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;colors_name&lt;/code&gt; variable to the scheme’s name
(&lt;em&gt;example&lt;/em&gt;, in this example).&lt;/p&gt;

&lt;p&gt;The rest of the script defines the color scheme itself.  This is accomplished
primarily through the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;highlight&lt;/code&gt; (or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hi&lt;/code&gt;) command.  Each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;highlight&lt;/code&gt; command
sets the colors for a single syntax group.  Setting the colors for the
&lt;em&gt;Comments&lt;/em&gt; group might look like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;k&quot;&gt;hi&lt;/span&gt; Comment ctermbg&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;black ctermfg&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;darkgrey guibg&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;#000000&lt;/span&gt; guifg&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mh&quot;&gt;#777777&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To see the full list of Vim’s syntax groups (along with their current
highlight settings), run the following command from within the editor:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;source&lt;/span&gt; $VIMRUNTIME&lt;span class=&quot;sr&quot;&gt;/syntax/&lt;/span&gt;hitest&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;vim&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;testing-runtime-features&quot;&gt;Testing Runtime Features&lt;/h2&gt;

&lt;p&gt;Because the color scheme is simply a Vim script, you can conditionalize the
definitions based on various runtime values.  The presence of the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gui_running&lt;/code&gt; feature indicates that the Vim GUI is running, for example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;has&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;gui_running&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&quot; GUI colors&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&quot; Non-GUI (terminal) colors&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;endif&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And the terminal’s color range – the number of available colors – can be
queried via the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;t_Co&lt;/code&gt; variable:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &amp;amp;&lt;span class=&quot;nb&quot;&gt;t_Co&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;255&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&quot; More than 256 colors are available&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;endif&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;additional-configuration&quot;&gt;Additional Configuration&lt;/h2&gt;

&lt;p&gt;Color scheme scripts can support basic configuration using global variables.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exists&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;g:example_force_dark&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;background&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dark&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;endif&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The user should set this variable in his &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt; file before loading the
color scheme script.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-vim&quot; data-lang=&quot;vim&quot;&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;g:example_force_dark&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;colorscheme&lt;/span&gt; example&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;(Global variables can be “unset” using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unlet&lt;/code&gt; command.)&lt;/p&gt;

</content>
 </entry>
 
 
</feed>
