Skip to content

Complete idiot's introduction to yaml

Protected edited this page Aug 9, 2011 · 17 revisions

YAML is a very simple, text/human-readable annotation format that can be used to store data. It is natively supported by Bukkit and almost every plugin uses it. CraftIRC's configuration file, config.yml, uses it; It's important that you do not break the formatting while you are editing it or the plugin won't run.

Basic principles to remember while working with config.yml:

  • Always save using the UTF-8 encoding to minimize the possibility of errors.
  • Never, EVER use the TAB character anywhere in it.
  • Editing with a WYSIWYG text processor, such as Microsoft Word, is not recommended.
  • Use a monowidth/monospaced font to view the contents. Examples you may have in your computer: Fixedsys, Lucida Console, Consolas, Monaco, DejaVu Sans Mono, Courier New.

Whenever you see the # character anywhere in the file that isn't first enclosed in '' (quotes) or "" (double quotes), it marks the beginning of a comment. This means all the text after it, up until the end of the line, is completely ignored and has no effect. You can use this to write notes on the file or temporarily disable one or more options.

These are all comments:

#debug: false
#Hello there, how are you?
debug: false # <- The line is read up to this character!

This is not commented:

name: '#changeme'

But this is!:

#name: '#changeme'

Key-value pairs

YAML keeps data stored as a map containing keys and values associated to those keys. This map is in no particular order, so you can reorder it at will. For example:

minecraft-tag: 'minecraft'
cancelled-tag: 'cancelled'