Here document: Difference between revisions

Content deleted Content added
Aartaka (talk | contribs)
Add ed example
Kennypete (talk | contribs)
Added Vim Script
Line 2,479:
WshShell.Popup "created " & strFileNameOUT, 3, "Completed", 64
</syntaxhighlight>
 
=={{header|Vim Script}}==
 
Vim ''does'' have here documents (:h [https://vimhelp.org/eval.txt.html#%3Alet-heredoc :let-heredoc]). A heredoc sets an internal variable to a list containing the lines of text bounded by an end marker string, which must start with an uppercase letter. Therefore, to output the exact literal input, you need to join the list, either with builtin function [https://vimhelp.org/builtin.txt.html#join%28%29 join()], as in example 1, below, or use another function that joins inherently, as in example 2, below, which uses [https://vimhelp.org/builtin.txt.html#append%28%29 append()].
 
'''Example 1''' - simple, literal heredoc
<syntaxhighlight lang="vim">
let hw =<< END
Hello
World
END
echo join(hw, "\n")
</syntaxhighlight>
 
{{out}}
<pre>
Hello
World
</pre>
 
'''Example 2''' - evaluated heredoc
<syntaxhighlight lang="vim">
let d58 = "5 6 7 8"
let d =<< eval DOZEN
1 2 3 4 {d58}
9 10 11 12
DOZEN
call append(line('$'), d)
</syntaxhighlight>
 
{{out}}
<pre>
1 2 3 4 5 6 7 8
9 10 11 12
</pre>
 
<small>NB: The output of example 2 is appended to the end of the current buffer if [https://vimhelp.org/repeat.txt.html#%3Asource-range '<,'>so] is executed on the visual selection from the lines starting "let d58" to "call append".</small>
 
=={{header|V (Vlang)}}==