Gotcha! In a function, a:b means "the argument named b". However, c[a:b] is an error even outside a function.
c[a:b] is an error because a: is a known namespace (function arguments) c[b,d] is an error because b is a known namespace (buffer variables) c[x:y] is not an error, even with no spaces. Best regards, Tony. On Sun, Sep 15, 2019 at 9:47 AM Tony Mechelynck <antoine.mechely...@gmail.com> wrote: > > On Sun, Sep 15, 2019 at 8:55 AM Shidong Wang <wsd...@outlook.com> wrote: > > > > Hello, I am not sure if it is a bug, but it always make me confuses: > > > > here is a exmaple: > > > > func Test() > > let c = 'sss' > > let a = 1 > > let b = 2 > > echo c[a:b] > > endf > > > > then call Test(), you will get error, Undefined variable: a:b > > > > of cause this can be avoided by changing the last line to echo c[a : b] > > Hm, the help defines an expr8 of that type as expr8[expr1a : expr1b] > (with spaces around the colon) then proceeds to give examples, all of > which have only empty or numeric indices without spaces around the > colon. > > Looks like spaces are better (less confusing for the Vim parser, > maybe) whenever the index is _other_ than empty or purely numeric. > > Bram: Bug or feature? > > > Best regards, > Tony. -- -- 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 vim_dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAJkCKXvA5cCqP102NMrQJQ3TtY-NxhWPdvyzh0SsrA19gbgiPw%40mail.gmail.com.