Appendix E. Vim Syntax Highlighter

Syntax highlighting is incredibly useful, in addition to making reading AsciiDoc documents much easier syntax highlighting also helps you catch AsciiDoc syntax errors as you write your documents.

The AsciiDoc ./vim/ distribution directory contains Vim syntax highlighter and filetype detection scripts for AsciiDoc. Syntax highlighting makes it much easier to spot AsciiDoc syntax errors.

If Vim is installed on your system the AsciiDoc installer (install.sh) will automatically install the vim scripts in the Vim global configuration directory (/etc/vim).

You can also turn on syntax highlighting by adding the following line to the end of you AsciiDoc source files:

// vim: set syntax=asciidoc:
[Tip]

Bold fonts are often easier to read, use the Vim :set background=dark command to set bold bright fonts.

[Note]

There are a number of alternative syntax highlighters for various editors listed on the AsciiDoc website.

E.1. Limitations

The current implementation does a reasonable job but on occasions gets things wrong:

  • Nested quoted text formatting is highlighted according to the outer format.
  • If a closing Example Block delimiter is sometimes mistaken for a title underline. A workaround is to insert a blank line before the closing delimiter.
  • Lines within a paragraph starting with equals characters may be highlighted as single-line titles.
  • Lines within a paragraph beginning with a period may be highlighted as block titles.