If you’ve done any work in Ansible you’ll know that it uses YAML files for the bulk on the configuration. Whilst you can just make do with a standard YAML syntax highlighting, Ansible uses variables inside lines and Jinja template tags that it would be nice to visually highlight.
First, you’ll need to install the Ansible syntax highlighting package.
Now, you should be able to select the syntax highlighting as ‘Ansible’ in the editor right-hand corner
Why aren’t my
.yml files being automatically marked as Ansible syntax files? Well, because they’re just YAML files!
To force them to be highlighted as Ansible, you’ll need to install the ApplySyntax plugin which gives you really fine-grained control over how files are highlighted based on their path or first line. Now, in your ApplySyntax user preferences, paste this:
This should highlight any Ansible .yml files in directories with ‘ansible’ in their name, or any of the common directories ‘roles’, ‘tasks’, ‘handlers’ etc used in Ansible projects.