Xtext provides an API to easily implement formatters for your language, which is used both when a user presses CTRL+SHIFT+F in the editor and when Xtext serializes EMF models.
For users, a good formatter is not only a convenience while typing, it also simplifies having a consistent formatting across all files of the project and avoid whitespace-changes in code reviews.
In this talk I will explain the formatter and its API based on a series of examples. The examples start with the most simple scenarios, continue with the most common scenarios and also include some advanced scenarios such as pattern-based formatting and formatter preferences. Also I will show how to debug formatter implementations, how to make sense from the exceptions you may encounter, and how to test your formatter implementation.