Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 1563771179
Fetching contributors…

Cannot retrieve contributors at this time

95 lines (70 sloc) 3.364 kB
<h3 id="redefining-highlight-groups">Redefining Highlight Groups</h3>
<p>You want to change the colours of specific elements of the display. For
example, you want text to be white on a black background.</p>
<p>Use the <tt>:highight <var>group</var> <var>definition</var></tt> command.</p>
<p>A <i>highlight group</i> (<var>group</var>) is an element of the display
whose colours can be customised. Some of the default highlight groups are:</p>
<p><span class="todo">Is a list the right way to present this?</span></p>
<dd>Character under the cursor.</dd>
<dd>Command line error messages.</dd>
<dd>Normal text.</dd>
<dd>Text selected under Visual mode.</dd>
<p>The <var>definition</var> is a list of key-value pairs. For example, the
following sets the terminal foreground colour to black and
the terminal background colour to yellow: </p>
<pre><code>:highlight Normal ctermfg=black ctermbg=yellow</code></pre>
<p>These are some common arguments:</p>
<dd>Terminal foreground colour.</dd>
<dd>Terminal background colour.</dd>
<dd>Terminal font style, e.g. <i>bold</i>, <i>italic</i>,
<dd>GUI foreground colour.</dd>
<dd>GUI background colour.</dd>
<p>Apart from <i>term</i>, these arguments take a colour name or number as a
value. Recognised colour names include <i>black</i>, <i>brown</i>,
<i>grey</i>, <i>blue</i>, <i>green</i>, <i>cyan</i>, <i>magenta</i>,
<i>yellow</i>, and <i>white</i>.</p>
<p>The arguments that are not supplied retain their previous values. For
example, <tt>:highlight Normal\ ctermbg=white</tt> changes the background
colour to <i>white</i>, but keeps the previous foreground colour.</p>
<p>Let's look at some examples:</p>
<li><tt>:highlight Visual term=bold</tt> - Text that has been selected using
<i>Visual</i> mode is rendered in bold.</li>
<li><tt>:highlight Comment ctermfg=grey ctermbg=white term=bold</tt> -
Comments are rendered in bold, grey text.</li>
<p>Normally you'll select a <a href="#changing-colour-scheme">colour
scheme</a>, and not define highlighting groups at all. Occasionally, though,
you want more control over colours or need to edit a syntax file. That's
where the <tt>:highlight</tt> command comes in.</p>
<p>Before you change highlight groups you may like to check their current
values. You can do this with <tt>:highlight <var>group</var></tt>. To view
all current settings use <tt>:highlight</tt>.</p>
<blockquote class="callout">
<h5 id="defining-highlight-group">Defining a Highlight Group</h5>
<p>You can define your own highlight group by using the <tt>:highlight</tt>
command as described above with a group name of your choice. To select what is
highlighted you use <tt>:match <var>group</var>
/<var>pattern</var>/</tt>. For example:</p>
<pre><code>:highlight Elephant ctermbg=grey ctermfg=white
:match Elephant /\celephant/</code></pre>
<p>This renders all occurrences of the word <i>elephant</i>, regardless of
case due to the <tt>\c</tt> escape, in white on grey.
Jump to Line
Something went wrong with that request. Please try again.