Marcin Szamotulski wrote: > On 15:33 Sat 22 Mar , Bram Moolenaar wrote: > > > > ZyX wrote: > > > > > Consider the following script: > > > > > > execute 'if 0' > > > echo 'Not shown' > > > else > > > echo 'Shown' > > > endif > > > > > > . If you source it you find that instead of 3 errors (“missing > > > :endif”, “:else without :if”, “:endif without :if”) and two messages > > > (“Not shown” and “Shown”) you will see one message (“Shown”) and no > > > errors. > > > > > > Note that `execute 'if 0'` is explicitly forbidden in help: > > > > > > > Note: The executed string may be any command-line, but > > > > you cannot start or end a "while", "for" or "if" > > > > command. Thus this is illegal: > > > > :execute 'while i > 5' > > > > :execute 'echo "test" | break' > > > > The docs are wrong, using "if" is allowed. The other two are not. > > Well, this script works just fine for me: > > let i = 0 > execute 'while i < 10' > let i += 1 > echo 1 > endwhile > > also this one works: > > execute 'for i in range(10)' > echo i > endfor
I got confused by the example in the docs. It looks like :break and :continue don't work in :execute. I suppose the implementation got improved after this documentation was written. -- I used to wonder about the meaning of life. But I looked it up in the dictionary under "L" and there it was - the meaning of life. It was less than I expected. - Dogbert /// 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]. For more options, visit https://groups.google.com/d/optout.
