2016-03-17 18:16 GMT+03:00 Giuseppe <[email protected]>:
> This example works fine
>
> let a = [
> \ 0
> \ ]
>
> but if I try to annotate the elements in some way I'm greeted by an error
> as get_list_tv greedily searches for a , or a ] and the eval functions
> don't seem to care much about comments.
>
> let a = [
> \ 0 " Comment
> \ ]
> let a = [ " Comment
> \ 0
> \ ]
>
>
Before trying to put comments somewhere you need to understand that
1. Comments are only present in command context. You cannot write
:echo 42 " This echoes 42
because :echo starts expression context and in that context `"` starts a
string literal. Some command definitions allow comments in their context so
`set ai " Set &autoindent` works, treating `"` just like newline or bar,
but this does not apply to `:let`.
2. VimL does not have normal multiline processing. When executing a script
file (note: *a script file*, this does not apply to `:execute`) Vim simply
checks whether next line starts with `\` (possibly preceded by a number of
whitespaces) and if yes, lines are joined. So
:let a = [
\ 0 " Comment
\ ]
is turned into
:let a = [ 0 " Comment ]
*and only then* it reaches executor (which does parsing).
With comment character equal to `"` you cannot do much with 1, though it is
still possible to treat string literals without closing `"` as nothing.
With current executor (which does parsing while executing) you cannot
really do anything with 2 without major rewrite of all eval* functions.
Also note that I saw tricks like
:call map(list, '
\ ReallyLongExprStart(v:val)
\ + ReallyLongExprEnd(v:key)
\ ')
, so for backward compatibility reasons your request cannot be fulfilled
simply because `"` without closing `"` on the same line may actually start
a string literal with closing `"` on some other line. In the example I used
`'` because I did not see such expressions with `"`, but this does not mean
they do not exist.
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly or view it on GitHub
> <https://github.com/vim/vim/issues/694>
>
> --
> --
> 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].
> For more options, visit https://groups.google.com/d/optout.
>
--
--
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].
For more options, visit https://groups.google.com/d/optout.