This post has moved to a new home. Syntax highlighting for Nginx in VIM
home

Syntax highlighting for Nginx in VIM

10 Jun 2012

Thanks to Evan Miller, adding VIM syntax highlighting for Nginx config files is a breeze.

First, install VIM if you haven't already. On Arch Linux, it goes like this:

>pacman -Sy vim

Create a folder for your VIM syntax files.

>mkdir -p ~/.vim/syntax/

Download the syntax highlighting plugin.

>curl http://www.vim.org/scripts/download_script.php?src_id=14376 -o ~/.vim/syntax/nginx.vim

Add it to VIM's file type definitions. Make sure to adjust the path to your Nginx installation if you need to.

>echo "au BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx" >> ~/.vim/filetype.vim

Now enable syntax highlighting in your .vimrc file.

>echo "syntax enable" >> ~/.vimrc

That's it. Now you'll have nice colors when you edit your Nginx configs with VIM!

>vim /etc/nginx/conf/nginx.conf

Screenshot of VIM with syntax highlighting in an Nginx config file.

blog comments powered by Disqus