Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 4. Manually adding the Ansible language to YAML files
The Ansible VS Code extension works only when the language associated with a file is set to Ansible. The extension provides features that help create Ansible playbooks, such as auto-completion, hover, and diagnostics.
The Ansible VS Code extension automatically associates the Ansible language with some files. The procedures below describe how to set the language for files that are not recognized as Ansible files.
4.1. Associating the Ansible language to YAML files Copier lienLien copié sur presse-papiers!
The following procedure describes how to manually assign the Ansible language to a YAML file that is open in VS Code.
Procedure
- Open or create a YAML file in VS Code.
- Hover the cursor over the language identified in the status bar at the bottom of the VS Code window to open the Select Language Mode list.
Select Ansible in the list.
The language shown in the status bar at the bottom of the VS Code window for the file is changed to Ansible.
4.2. Adding persistent file association for the Ansible language to settings.json Copier lienLien copié sur presse-papiers!
Instead of manually associating the Ansible language to YAML files, you can add file association for the Ansible language in your settings.json file.
Procedure
Open the
settings.jsonfile:-
Click
to open the command palette. -
Enter
Workspace settingsin the search box and select Open Workspace Settings (JSON).
-
Click
Add the following code to
settings.json.Copy to Clipboard Copied! Toggle word wrap Toggle overflow