Skip to content

Commit 232e7bd

Browse files
authored
Move section on indented strings after string interpolation (#1030)
Proposing to move the "_Indented strings_" section after "_String interpolation_" because I think it fits better there logically. Also added a note that string interpolation works in indented strings as well.
1 parent 439f2d8 commit 232e7bd

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

source/tutorials/nix-language.md

+48-45
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,54 @@ in
876876

877877
<!-- TODO: link to escaping rules -->
878878

879+
(indented-strings)=
880+
### Indented strings
881+
882+
Also known as “multi-line strings”.
883+
884+
The Nix language offers convenience syntax for character strings which span multiple lines that have common indentation.
885+
886+
Indented strings are denoted by *double single quotes* (`'' ''`).
887+
888+
Example:
889+
890+
```{code-block} nix
891+
:class: expression
892+
''
893+
multi
894+
line
895+
string
896+
''
897+
```
898+
899+
```{code-block}
900+
:class: value
901+
"multi\nline\nstring\n"
902+
```
903+
904+
Equal amounts of prepended white space are trimmed from the result.
905+
906+
Example:
907+
908+
```{code-block} nix
909+
:class: expression
910+
''
911+
one
912+
two
913+
three
914+
''
915+
```
916+
917+
```{code-block}
918+
:class: value
919+
"one\n two\n three\n"
920+
```
921+
922+
:::{note}
923+
Indented strings also support [string interpolation](string-interpolation).
924+
For details check the [documentation on string literals in the Nix language](https://nix.dev/manual/nix/2.24/language/syntax#string-literal).
925+
:::
926+
879927
(file-system-paths)=
880928
### File system paths
881929

@@ -1003,51 +1051,6 @@ While you will encounter many such examples, we recommend to [avoid lookup paths
10031051
[nixpkgs]: https://github.com/NixOS/nixpkgs
10041052
[manual-primitives]: https://nix.dev/manual/nix/stable/language/values.html#primitives
10051053

1006-
(indented-strings)=
1007-
### Indented strings
1008-
1009-
Also known as “multi-line strings”.
1010-
1011-
The Nix language offers convenience syntax for character strings which span multiple lines that have common indentation.
1012-
1013-
Indented strings are denoted by *double single quotes* (`'' ''`).
1014-
1015-
Example:
1016-
1017-
```{code-block} nix
1018-
:class: expression
1019-
''
1020-
multi
1021-
line
1022-
string
1023-
''
1024-
```
1025-
1026-
```{code-block}
1027-
:class: value
1028-
"multi\nline\nstring\n"
1029-
```
1030-
1031-
Equal amounts of prepended white space are trimmed from the result.
1032-
1033-
Example:
1034-
1035-
```{code-block} nix
1036-
:class: expression
1037-
''
1038-
one
1039-
two
1040-
three
1041-
''
1042-
```
1043-
1044-
```{code-block}
1045-
:class: value
1046-
"one\n two\n three\n"
1047-
```
1048-
1049-
<!-- TODO: See [escaping rules](). -->
1050-
10511054
(functions)=
10521055
## Functions
10531056

0 commit comments

Comments
 (0)