In :help let-heredoc
it explains that one can set a variable to a 'heredoc' where each line of the heredoc becomes an entry in a list as follows:
let text =<< trim END
if ok
echo 'done'
endif
END
:echo text
The above example produces:
['if ok', ' echo ''done''', 'endif']
That's fine, but I would like to embed this list into an entry in a dictionary so that the dictionary variable contains multiple heredocs as values each with a key, as follows:
{'code1': ['if ok', ' echo ''done''', 'endif']}
{'code2': ['if something', ' echo something else', 'endif']}
How can I do this in Vim? Also, Neovim doesn't appear to have heredocs as nothing comes up in the help files. How can I achieve the same effect in Neovim to make this cross-editor compatible? (In Neovim, the first block of code evaluates to an E15: Invalid expression
error.)
EDIT:
Just for some clarificaton, I'm imagining there must be some way to add lines to a dictionary like the following:
let testdictionary = {'code1': ' some code!', 'code2': 'some code again'}
echo testdictionary
to something along those lines:
let testdictionary = {'code1': << END
some code!
END
\ , 'code2': 'some code again'}
echo testdictionary
...and for both to produce a dictionary that looks like: {'code1': ' some code!', 'code2': some code again''}
And that if there are more than one line in the heredoc, that it gets turned into a list: {'code1': [' some code!', 'line2', 'line3'], 'code2': some code again''}
Any clean solution would be helpful.
:version
or with:checkhealth
or anything else I have tried.