From bacb5021d4eff33c67eb659fb01125b2abcacd79 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 21:08:00 +0800 Subject: 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 vim/vim#10327) https://github.com/vim/vim/commit/2eaef106e4a7fc9dc74a7e672b5f550ec1f9786e Cherry-pick Test_Debugger_breakadd_expr() from Vim. Co-authored-by: LemonBoy --- runtime/doc/eval.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c8eea03f5f..518a190d3c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1406,6 +1406,26 @@ to be doubled. These two commands are equivalent: > if a =~ '\s*' +------------------------------------------------------------------------------ +interpolated-string *interp-string* + +$"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* -- cgit