Keep calm and code. Or do some other stuff.

Enabling syntax highlighting in vim for asciidoc formatted files is easy. Really.

grab the asciidoc vim syntax file

The asciidoc project on github is your friend.

At first create a syntax Folder within your .vim directory.

mkdir ~/.vim/syntax

Then grab a copy of the asciidoc vim syntax file.

wget -O .vim/syntax/asciidoc.vim

That’s all.

You can enable syntax highlighting for asciidoc with the following command in vim.

:syn on
:set syn=asciidoc

Further information about vim syntax highlighting:

:help syntax

Or visit the syntax documentation at sourceforge.

Filetype detection

It’s good to know how to enable syntax highlighting manually. But it’s much more comfortable to enable syntax highlighting based on the filetype I’m working with.

Create the ftdetect directory within your .vim directory.

mkdir ~/.vim/ftdetect

Create a file called asciidoc.vim with the following content.

au BufRead,BufNewFile *.adoc        setfiletype asciidoc
au BufRead,BufNewFile *.asciidoc    setfiletype asciidoc

You need to restart your running vim instance. Next time you open a file with suffix *.adoc or *.asciidoc the highlighting for asciidoc gets automatically loaded.

See new-filetype documentation or execute :help new-filetype for more information.

2014 - 2017 | Mixed with Foundation v6.2.3 | Baked with JBake v2.5.1