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 Ah, that's where it comes from. It's based on the assumption that the script is indented with tabs, and that the input does not start with any tabs. I think both assumptions are not always valid. Or even rarily valid if you look at Vim scripts. > > 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". If we use "trim" then it's still similar to what bash does, but at the same time we make clear that it's not exactly the same. > > 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. Yeah, I think this works better, especially that it allows for indent in the literal lines. Except for the first one. -- Engineers will go without food and hygiene for days to solve a problem. (Other times just because they forgot.) (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- 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/201905181652.x4IGqL4u002228%40masaka.moolenaar.net. For more options, visit https://groups.google.com/d/optout.
