Hi Bram, On Sat, May 18, 2019 at 4:05 AM Bram Moolenaar <[email protected]> wrote: > > > Yegappan wrote: > > > > > When converting test29 into a new style test, I came across several > > > > instances where multiple lines of text need to be stored in a variable. > > > > I used the following method to do it: > > > > > > > > new > > > > insert > > > > some text > > > > some text > > > > some text > > > > . > > > > > > > > let text = getline(1, '$') > > > > > > > > You can also use a list literal to store the lines. But it is not > > > > readable. > > > > > > > > It will be useful to support a HERE document syntax for assigning > > > > multiple > > > > lines of text to a variable. Something along the lines of (similar to > > > > the shell > > > > here document syntax): > > > > > > > > let text <<HERE > > > > some text > > > > some text > > > > HERE > > > > > > Yeah, the list syntax is OK, but when the text contains quotes it gets a > > > bit messy. > > > > > > We already use this for Python, Lua, etc. > > > > > > > I have created the PR #4386 that implements the support for this. > > > > https://github.com/vim/vim/pull/4386 > > Thanks! > > I'm not sure why you added the feature to trim tabs. >
This is to be consistent with the here document syntax used in shell scripts like bash: https://www.gnu.org/software/bash/manual/html_node/Redirections.html#Here-Documents http://tldp.org/LDP/abs/html/here-docs.html > > Why not all white space? I suppose it's for things like this: > Yes. This is for indenting the here document lines. > > func GetColors() > let colors =<< END > blue > red > green > END > return colors > endfunc > > This looks better: > > func GetColors() > let colors =<< trim END > blue > red > green > END > return colors > endfunc > > The "-" is cryptic, is this coming from another language? I would > prefer something easily understandable, like "trim". > I wanted to keep it consistent with the shell script syntax. So I used "-". I can change it to "trim". > > I would think that when "trim" is used, then the indent of the first > line is removed, and the same amount is removed from following lines. > And the marker must have less indent. This allows for: > I will make this change to remove the same amount of indentation from all the lines in the here document as the first line. - Yegappan > func GetNested() > let nested =<< trim END > header1 > item1 > item2 > header2 > item3 > END > return nested > endfunc > > Then three space of indent before the item lines is preserved. > -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAAW7x7nuNKO6DtAR%2BpNfk_Shgp6BMJFHTDVWLfqDnmGORU6vWA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
