On Sun, 3 Sep 2006 at 6:23am, A.J.Mechelynck wrote: > Hari Krishna Dara wrote: > > I just want to thank Bram specially for all the scripting related > > improvements that were done in Vim7. After converting most of my plugins > > to use Lists instead of multvals plugin, other than having a cleaner and > > more compact code, my productivity has improved significantly (and using > > multvals itself was very productive over using simple > > curly-braces-names, which means for those not using multvals before, it > > will be a tremendous change). If you just compare my 4.0 version of > > perforce plugin with that of previous, you would see what I am talking > > about. Also, I have been making a few additional changes today and got > > some features done very easily, and previously I kept pushing them > > because it would have been very complex/time-consuming. E.g., as part of > > one feature, I had to determine what files need their status refreshed > > after updating a changelist, and I could do it in just 3 lines (to > > determine the outersection of prior and new filelist that the changelist > > contained). > > > > The Lists, Hashes (and their constructs such as :for, map(), filter()), > > and a few other changes such as, <buffer> autocommands and <expr> > > maps/abbreviations etc. avoided a lot of complexity in my plugins. > > These features will go a long way in bringing more value to Vim, as > > more complex plugins can be written with less effort and more people > > will be willing to contribute plugins. > > > > I recently observed (from a Tony's post, I think) that you can now use > > += and -=, and this is a very nice addition to avoid some repetition. > > I think I noticed it in one of Bram's posts, but I'm not sure. > > > > > I still miss pre and post increment and decrement operators (avoids a > > separate :let command by itself), and indexed for loops. > > I'm not sure what you call indexed for loops, but Vim 7 now has two > looping structures. In addition to the time-honored "while": incremental > > let i=initial > while i <= final > " do something > i = i + 1 > endwhile > > or yes/no on a criterion set inside the (potentially infinite) loop > > let done = 0 > while ! done > " do something; set done to nonzero if finished > endwhile > > there is now also > > for i in List > " do something > endfor > > where List can be the result of the range() function, so that now the > first-type "while" can be replaced by a "for" if compatibility with > earlier versions is not important. (I noticed this ":for" command in > Bram's example in the help about the 'tabline' option.) > > > For the later, > > I get around using the below construct: > > > > let loop_index = <initial value> > > while <condition> > > try > > <body> > > finally > > let loop_index = <new value> > > endtry > > endwhile > > > > This takes care of any :continue that you use inside, but this is > > clumsy. > > > > Best regards, > Tony. > >
I knew about the for with range() which is equivalent to a for loop with an index, but this is not efficient as it pre-generates a list of numbers (which is why python also has an irange(), an enum). Besides, you can use range() only for numbers, but I think you rarely need to work with anything else other than a range of numbers or a list. -- Thanks, Hari __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
