Hi Bram, On Sat, May 18, 2019 at 9:52 AM Bram Moolenaar <[email protected]> wrote: > > Yegappan wrote: > > > > > > > > > > > > > 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 rarely > 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. >
I have updated the PR to use "trim" instead of "-" and also to remove all the leading indentation matching the indentation used in the 'let' line. - Yegappan -- -- 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/CAAW7x7mgAxv-YSgxWwC%2BSfo2u%2B3kfp0dWu0NnAd5168rbm8BRA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
