comparison runtime/doc/eval.txt @ 28718:723c7d940cba

patch 8.2.4883: string interpolation only works in heredoc Commit: https://github.com/vim/vim/commit/2eaef106e4a7fc9dc74a7e672b5f550ec1f9786e Author: LemonBoy <thatlemon@gmail.com> Date: Fri May 6 13:14:50 2022 +0100 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)
author Bram Moolenaar <Bram@vim.org>
date Fri, 06 May 2022 14:15:03 +0200
parents 060fc3b69697
children b96ceb97e896
comparison
equal deleted inserted replaced
28717:3953457538c9 28718:723c7d940cba
1520 Single quoted strings are useful for patterns, so that backslashes do not need 1520 Single quoted strings are useful for patterns, so that backslashes do not need
1521 to be doubled. These two commands are equivalent: > 1521 to be doubled. These two commands are equivalent: >
1522 if a =~ "\\s*" 1522 if a =~ "\\s*"
1523 if a =~ '\s*' 1523 if a =~ '\s*'
1524 1524
1525
1526 interpolated-string *interp-string* *E256*
1527 --------------------
1528 $"string" interpolated string constant *expr-$quote*
1529 $'string' interpolated literal string constant *expr-$'*
1530
1531 Interpolated strings are an extension of the |string| and |literal-string|,
1532 allowing the inclusion of Vim script expressions (see |expr1|). Any
1533 expression returning a value can be enclosed between curly braces. The value
1534 is converted to a string. All the text and results of the expressions
1535 are concatenated to make a new string.
1536
1537 To include an opening brace '{' or closing brace '}' in the string content
1538 double it.
1539
1540 Examples: >
1541 let your_name = input("What's your name? ")
1542 echo $"Hello, {your_name}!"
1543 echo $"The square root of 9 is {sqrt(9)}"
1525 1544
1526 option *expr-option* *E112* *E113* 1545 option *expr-option* *E112* *E113*
1527 ------ 1546 ------
1528 &option option value, local value if possible 1547 &option option value, local value if possible
1529 &g:option global option value 1548 &g:option global option value