# String line continuation

**URL:** <https://discourse.julialang.org/t/string-line-continuation/130757>\
**Category:** New to Julia\
**Tags:** strings\
**Created:** [July 15, 2025, 8:13pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757 "2025-07-15T20:13:28Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 8:13pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/1 "2025-07-15T20:13:28Z")

</div>

the docs make it sound like you can continue strings:  
[“long lines can be broken up”](https://docs.julialang.org/en/v1/manual/strings/#String-Basics#:~:text=Long%20lines%20in%20strings%20can%20be%20broken%20up)  
but it’s giving me an error in the repl:

```julia
julia> "This is a long \
ERROR: ParseError:
# Error @ REPL[1]:1:17
"This is a long \
# ╙ ── invalid escape sequence
Stacktrace:
 [1] top-level scope
   @ none:1

```

what am I doing wrong…

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 15, 2025, 8:21pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/2 "2025-07-15T20:21:25Z")

</div>

Works for me:

```julia
julia> "This is a very \
       long string"
"This is a very long string"

```

Which Julia version do you use? Which OS? Which terminal?

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 8:24pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/3 "2025-07-15T20:24:02Z")

</div>

on ubuntu 22, gnome terminal, julia version 1.11.6  
I thought there was some command like `osinfo()` or something but can’t remember it

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 15, 2025, 8:24pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/4 "2025-07-15T20:24:32Z")

</div>

`versioninfo()`

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 8:25pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/5 "2025-07-15T20:25:00Z")

</div>

```julia
julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × 12th Gen Intel(R) Core(TM) i7-1265U
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 15, 2025, 8:28pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/6 "2025-07-15T20:28:39Z")

</div>

If I put a space after the backslash I can reproduce the problem:

```julia
julia> "This is a very \ 
       long string"
ERROR: ParseError:
# Error @ REPL[4]:1:17
"This is a very \ 
# └┘ ── invalid escape sequence
Stacktrace:
 [1] top-level scope
   @ none:1

```

The error message is bad. But if you type \<backslash\>\<enter\> it just works.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 8:29pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/7 "2025-07-15T20:29:43Z")

</div>

```julia
julia> "no space after\
ERROR: ParseError:
# Error @ REPL[1]:1:16
"no space after\
# ╙ ── invalid escape sequence
Stacktrace:
 [1] top-level scope
   @ none:1

julia> "one space after\ 
ERROR: ParseError:
# Error @ REPL[2]:1:17
"one space after\ 
# └┘ ── invalid escape sequence
Stacktrace:
 [1] top-level scope
   @ none:1

```

---

<div class="post-metadata">

**Author:** ![JuhaNuutila](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JuhaNuutila](https://discourse.julialang.org/u/JuhaNuutila)\
**Post date:** [July 15, 2025, 8:32pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/8 "2025-07-15T20:32:37Z")

</div>

It seems I can continue strings with two backslashes (\) in Julia 1.11.6, but not with a single backslash

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 8:35pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/9 "2025-07-15T20:35:01Z")

</div>

two backslashes create a single backslash as expected on my end:

```julia
julia> "no backslashes
       some text"
"no backslashes\nsome text"

julia> "two backslashes\\
       some text"
"two backslashes\\\nsome text"

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 15, 2025, 8:35pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/10 "2025-07-15T20:35:44Z")

</div>

For me it sometimes works, sometimes it doesn’t. Could not figure out why or when yet. Also on Ubuntu and Julia 1.11.6.  
Perhaps this is a [Heisenbug](https://www.rookout.com/blog/fantastic-bugs-and-how-to-resolve-them-ep1-heisenbugs/)?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [July 15, 2025, 8:41pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/11 "2025-07-15T20:41:42Z")

</div>

I’m also not sure what’s going on but probably an issue with JuliaSyntax.

An effective workaround is to use Alt+Enter at the end of the line and continue the string on the next line.

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 8:45pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/12 "2025-07-15T20:45:22Z")

</div>

alt-enter didn’t work either:

```julia
julia> "some test
       more chars"
"some test\nmore chars"

```

using a file works though:

```julia
$ cat tmp.jl
@show "some text\
more chars"
$ julia tmp.jl
"some textmore chars" = "some textmore chars"

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [July 15, 2025, 8:57pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/13 "2025-07-15T20:57:17Z")

</div>

For me, \<backslash\>\<alt\>+\<enter\> at the end of the line worked three times (did not try more often). I guess, worth to create a bug report. It should always work, also without using the \<alt\> key.

Who creates a bug report? [GitHub · Where software is built](https://github.com/JuliaLang/julia/issues)

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 9:00pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/14 "2025-07-15T21:00:14Z")

</div>

nice! that got it for me ^^

```julia
julia> "some chars\
       more"
"some charsmore"

```

(very much agree should work without alt; had to throw a thing together to suppress other stuff since alt-enter opens a new terminal on my system)

---

<div class="post-metadata">

**Author:** ![rokke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rokke/32/222691_2.png) [@rokke](https://discourse.julialang.org/u/rokke)\
**Post date:** [July 15, 2025, 9:01pm UTC](https://discourse.julialang.org/t/string-line-continuation/130757/15 "2025-07-15T21:01:05Z")

</div>

it sounds like we have different bugs, so potentially both?

one created [here](https://github.com/JuliaLang/julia/issues/59015)
