Enable Nginx syntax highlighting in Vim

Vim in Ubuntu 16.04 LTS and even Ubuntu 18.04 LTS by default doesn’t support syntax highlighting for Nginx configuration files. However, we can enable it manually by copying the next commands and executing them in a terminal as root user:

mkdir -p ~/.vim/syntax/
wget https://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim
cat > ~/.vim/filetype.vim << EOF
au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif

Leave a Comment