Does Vimscript allow multi-line strings?
The python and ruby commands allow the format: :python << EOF
Can you do anything similar with strings?
You can have a string split across multiple lines by enclosing it in triple quotes. Alternatively, brackets can also be used to spread a string into different lines. Moreover, backslash works as a line continuation character in Python. You can use it to join text on separate lines and create a multiline string.
A verbatim string literal consists of an @ character followed by a double-quote character, zero or more characters, and a closing double-quote character. Not only does this allow multiple lines, but it also turns off escaping.
We can use string literal concatenation. Multiple string literals in a row are joined together: char* my_str = "Here is the first line." "Here is the second line."; But wait!
Vimscript does allow continuation of the previous line by starting the next with a backslash, but that isn't quite as convenient as a heredoc string such as you would find in Ruby, PHP, or Bash.
let g:myLongString='A string \ that has a lot of lines \ each beginning with a \ backslash to continue the previous one \ and whitespace before the backslash \ is ignored'
Have a look at the relevant documentation on line-continuation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With