Add support for here document in :let statement#4386
Add support for here document in :let statement#4386yegappan wants to merge 5 commits intovim:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4386 +/- ##
==========================================
+ Coverage 80.36% 80.37% +<.01%
==========================================
Files 109 109
Lines 142611 142659 +48
==========================================
+ Hits 114616 114659 +43
- Misses 27995 28000 +5
Continue to review full report at Codecov.
|
|
What is this for? We can already do e.g. In particular I see no need for the stripping aspect. When using :let inside a script we can also already use line continuation. So just do let foo="one
\two
\three
\four" |
|
Hi,
On Sat, May 18, 2019 at 6:41 AM chdiza ***@***.***> wrote:
What is this for? We can already do e.g. :let foo="oof\nbar\tbaz", right?
When you want to assign a lot of lines with indentation (for example, a code
snippet) to a variable, it is more readable and maintainable to use the
list of lines without quotes and "\" at the beginning of the line for line
continuation. This is used in various places in the Vim test scripts.
Using a string with embedded newlines or a list with line continuation and
quotation makes it harder to read and understand what the test is doing.
In particular I see no need for the stripping aspect. When using :let inside
a script we can also already use line continuation. So just do
When using the here document syntax, you may want to align the lines in
the here document with the surrounding code. The support for stripping
the leading indentation is meant for aligning the lines.
https://riptutorial.com/bash/example/2135/indenting-here-documents
- Yegappan
… let foo="one
\two
\three
\four"
|
|
What about making |
|
There are some patterns cannot work: e.g. a line starts with func Foo()
let x =<<
endfunc
.
endfunc
func Foo()
let x =<<END
a
END
endfunc
func Foo()
let x =<<END
python <<EOS
END
endfunc
|
|
Hi,
On Sun, May 19, 2019 at 10:04 AM ichizok ***@***.***> wrote:
There are some patterns cannot work: e.g. a line starts with endfunc append python...
The Vim script parser is interpreting the "endfunc" text within a here document
as a statement instead of treating simply as a text string. I don't
have a fix for this
currently.
- Yegappan
…
func Foo()
let x =<<
endfunc
..
endfunc
E193: :endfunction not inside a function
func Foo()
let x =<<END
a
END
endfunc
E126: Missing :endfunction
func Foo()
let x =<<END
python <<EOS
END
endfunc
E126: Missing :endfunction
|
|
Btw, when I need some heredoc data, I put a |
|
Yegappan wrote:
On Sun, May 19, 2019 at 10:04 AM ichizok ***@***.***> wrote:
>
> There are some patterns cannot work: e.g. a line starts with endfunc append python...
>
The Vim script parser is interpreting the "endfunc" text within a here document
as a statement instead of treating simply as a text string. I don't
have a fix for this
currently.
We handle this for "python << END", we can do something similar.
…--
It doesn't really matter what you are able to do if you don't do it.
(Bram Moolenaar)
/// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///
|
|
Hi,
On Sun, May 19, 2019 at 12:11 PM Houl ***@***.***> wrote:
Btw, when I need some heredoc data, I put a finish line in the code, followed
by a data section in heredoc notation which is later at "runtime" extracted
with a bit of Vimscript into a dict.
Hopefully the new heredoc feature will simplify this use case. Let us know
if you see any issues with this feature.
- Yegappan
|
Problem: Getting a list of text lines is clumsy. Solution: Add the =<< assignment. (Yegappan Lakshmanan, closes vim#4386)
No description provided.