Working on text files - GNU LilyPond
Description: GNU LilyPond

Next: How to read the tutorial, Previous: Simple notation, Up: First steps

#### 2.1.3 Working on text files

LilyPond input files are treated like files in most programming languages: they are case sensitive, white-space insensitive, expressions are formed with curly braces { }, and comments are denoted with `%` or `%{ .. %}`.

If the previous sentence sounds like nonsense, don't worry! We'll explain what all these terms mean:

- Case sensitive: it matters whether you enter a letter in lower case (i.e. `a, b, s, t`) or upper case (i.e. `A, B, S, T`). Notes are lower case: `{ c d e }` is valid input; `{ C D E }` will produce an error message.
- Whitespace insensitive: it does not matter how many spaces (or new lines) you add. `{ c d e }` means the same thing as `{ c d e }` and

                     {
           c                        d
             e }

  Of course, the previous example is hard to read. A good rule of thumb is to indent code blocks with either a tab or two spaces:

           {
             c d e
           }

- Expressions: Every piece of LilyPond input needs to have { curly braces } placed around the input. These braces tell LilyPond that the input is a single music expression, just like parenthesis ``()`' in mathematics. The braces should be surrounded by a space unless they are at the beginning or end of a line to avoid ambiguities.

  A function (such as `\relative { }` ) also counts as a single music expression.

- Comments: A comment is a remark for the human reader of the music input; it is ignored while parsing, so it has no effect on the printed output. There are two types of comments. The percent symbol ``%`' introduces a line comment; anything after ``%`' on that line is ignored. A block comment marks a whole section of music input as a comment. Anything that is enclosed in `%{` and `%}` is ignored. The following fragment shows possible uses for comments

           % notes for twinkle twinkle follow
             c4 c g' g a a g2

           %{
               This line, and the notes below
               are ignored, since they are in a
               block comment.

               g g f f e e d d c2
           %}

There are more tips for constructing input files in Suggestions for writing LilyPond files.

Next: How to read the tutorial, Previous: Simple notation, Up: First steps

This page is for LilyPond-2.10.33 (stable-branch).

Other languages: French.