1
0
forked from aniani/vim

patch 8.2.4883: string interpolation only works in heredoc

Problem:    String interpolation only works in heredoc.
Solution:   Support interpolated strings.  Use syntax for heredoc consistent
            with strings, similar to C#. (closes #10327)
This commit is contained in:
LemonBoy
2022-05-06 13:14:50 +01:00
committed by Bram Moolenaar
parent e7d6dbc572
commit 2eaef106e4
16 changed files with 364 additions and 137 deletions

View File

@@ -1523,6 +1523,25 @@ to be doubled. These two commands are equivalent: >
if a =~ '\s*'
interpolated-string *interp-string* *E256*
--------------------
$"string" interpolated string constant *expr-$quote*
$'string' interpolated literal string constant *expr-$'*
Interpolated strings are an extension of the |string| and |literal-string|,
allowing the inclusion of Vim script expressions (see |expr1|). Any
expression returning a value can be enclosed between curly braces. The value
is converted to a string. All the text and results of the expressions
are concatenated to make a new string.
To include an opening brace '{' or closing brace '}' in the string content
double it.
Examples: >
let your_name = input("What's your name? ")
echo $"Hello, {your_name}!"
echo $"The square root of 9 is {sqrt(9)}"
option *expr-option* *E112* *E113*
------
&option option value, local value if possible