Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Vimscript allow multi-line strings?

Tags:

vim

Does Vimscript allow multi-line strings?

The python and ruby commands allow the format: :python << EOF

Can you do anything similar with strings?

like image 261
William Bettridge-Radford Avatar asked May 10 '12 00:05

William Bettridge-Radford


People also ask

Can you have multiple lines in a string?

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.

Can double quote strings span multiple lines?

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.

How do I write a multi line string literal in C?

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!


1 Answers

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.

like image 194
Michael Berkowski Avatar answered Sep 23 '22 14:09

Michael Berkowski