Next: , Previous: , Up: formations   [Index]

52.9 Escape sequences for output lines

Format Escape Sequence: ~%

Newline. Parameter: N.

Without modifiers: output a newline character, or N many if a parameter is given. A newline (or a few newlines) can of course be output just by including them in the format string as "\n".

(format "A~%Z")         ⇒ "A\nZ"
(format "A~3%Z")        ⇒ "A\n\n\nZ"

~:% outputs line endings as carriage returns followed by newlines, as in "\r\n".

(format "A~:%Z")        ⇒ "A\r\nZ"
(format "A~3:%Z")       ⇒ "A\r\n\r\n\r\nZ"
Format Escape Sequence: ~&

Start a new line. Parameter: n.

Output a newline if not already at the start of a line. With a parameter, output that many newlines, but with the first only if not already at the start of a line.

(format "A~&Z")         ⇒ "A\nZ"
(format "A~3&Z")        ⇒ "A\n\n\nZ"

;; at the start of a line
(format "~&Z")          ⇒ "Z"
(format "~3&Z")         ⇒ "\n\nZ"
Format Escape Sequence: ~|

Formfeed character. Parameter: N.

Output a formfeed character, or N feeds if a parameter is given.

(format "A~|Z")         ⇒ "A\fZ"
(format "A~3|Z")        ⇒ "A\f\f\fZ"
Format Escape Sequence: ~\n

Continuation line. No parameters.

Skip this newline and any following whitespace in the format string, i.e. don’t send it to the output. This can be used to break up a long format string for readability, but not print the extra whitespace.

(format "abc~
         ~d def~
         ~d" 1 2)               ⇒ "abc1 def2"

(format "abc~\ndef~\nghi")      ⇒ "abcdefghi"

~:\n skips the newline but leaves any further whitespace to be printed normally.

(format "abc~:\n def~:\n ghi")  ⇒ "abc def ghi"

~@\n prints the newline then skips following whitespace.

(format "abc~@\n def~@\n ghi")  ⇒ "abc\ndef\nghi"

Next: , Previous: , Up: formations   [Index]