summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2022-05-06 13:14:50 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-06 13:14:50 +0100
commit2eaef106e4a7fc9dc74a7e672b5f550ec1f9786e (patch)
tree543832333e5ef90b9e51477457a7e65572274227 /runtime
parente7d6dbc5721342e3d6b04cf285e4510b5569e707 (diff)
patch 8.2.4883: string interpolation only works in heredocv8.2.4883
Problem: String interpolation only works in heredoc. Solution: Support interpolated strings. Use syntax for heredoc consistent with strings, similar to C#. (closes #10327)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 953227d21d..39208e48dc 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -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