If you’re working in VSCode (and similar funcationality probably exists in Atom and SublimeText as well), there is an extension called language-Ansible that will add syntax highlighting. Installing this in and of itself is great. However, without configuration, it won’t recognize any files as Ansible files. All your Ansible .yml files will still be presented with yaml highlighting in VSCode. You could use CMD+K, M and select Ansible every time you open a file, but that would stink. Instead, add something like the below snippet to the "files.associations": {} section in your user preferences:

"files.associations": {
  "vars": "ansible",
  "**/playbooks/**/*.yml": "ansible",
  "**/roles/**/*.yml": "ansible",
  "**/tasks/**/*.yml": "ansible",
  "**/vars/**/*.yml": "ansible",
  "**/playbooks/**/*.yml": "ansible",
  "**/*ansible*/**/*.yml": "ansible"
}

Enjoy your better Ansible formatting

More VSCode Tips

Better VSCode Icons

Ansible Autocomplete in VSCode