YAML functions
YAML button
Section titled “YAML button”The YAML button on the lower toolbar shows a dropdown menu with options that involve YAML processing:
- Sort matches from the current file
- Edit match sort settings
- Add word triggers to all non-regex matches in the current file
- Add case propagation to all non-regex matches in the current file
- Reorder top-level keys for all matches in the current file
- Indent the current file with 2 spaces (standard indentation)
- Flatten the current file (minimum indentation)
Check for duplicate triggers
Section titled “Check for duplicate triggers”There is an additional function that involves YAML processing, which is in the Tools menu. This function generates a report on duplicate triggers in matches from the match files in the active folder.
Sort matches
Section titled “Sort matches”The sort function generates a sorted copy of matches from the current file.
The copy is displayed in a new editor tab so that the output can be reviewed before use. Sorting is alphanumberic. All matches can be grouped together before sorting or matches can be grouped by match type and then sorted within each type. The preferred order of match types can be configured.
Sorting is Espanso-specific but is liable to the following limitations:
- A
global_vars
section below matches will remain below after sorting - An
imports
section below matches will remain below after sorting
Comment handling
Section titled “Comment handling”Any comment preceded with # that is immediately above a match will be sorted with the preceding match. This is because the sort function processes the matches
section on the basis of triggers.
Add word triggers
Section titled “Add word triggers”This function will generate a copy of the current file in which a word trigger is added to all matches. The copy is displayed in a new editor tab so that the output can be reviewed before use.
Add case propagation
Section titled “Add case propagation”This function will generate a copy of the current file in which case propagation is applied to all matches. The copy is displayed in a new editor tab so that the output can be reviewed before use.
Reorder keys
Section titled “Reorder keys”This function will generate a copy of the matches from the current file in which top-level keys are reordered for all matches. The copy is displayed in a new editor tab so that the output can be reviewed before use. Top-level keys include the following:
label
replace
search_terms
force_mode
propagate_case
uppercase_style
word
orleft_word
orright_word
The Reorder keys
dialog allows you to arrange the keys in any order.
Indent file
Section titled “Indent file”The indent function generates a copy of the current file in which indentation is revised. The copy is displayed in a new editor tab so that the output can be reviewed before use. There are two options:
- Standard indentation with 2 spaces (this is the usual YAML default)
- The current file is flattened so that indentation is reduced to a minimum (0 spaces)
The copy is displayed in a new editor tab so that the output can be reviewed before use.
It is important to note the following limitations:
- Layout of multi-line scalars can change during YAML processing
- Any comment preceded with # will be ignored during indentation and is not included in the output
Check for parser errors
Section titled “Check for parser errors”This function will check all match files in the active folder for YAML parser errors.