Re: Testing for last item in a list

2010-11-15 Thread ZyX
Reply to message «Re: Testing for last item in a list», sent 10:32:22 15 November 2010, Monday by Jürgen Krämer: > I don't think so, Tim. If "is" is used as the comparison operator for > anything else than a List or a Dictionary it is equivalent to "==" (see &g

Re: Testing for last item in a list

2010-11-14 Thread Jürgen Krämer
Hi, Jürgen Krämer schrieb: > > Tim Johnson wrote: >> * ZyX [101112 12:17]: >>> >>> for line in lines >>> execute "normal! i".line >>> " " May be replaced with >>> " call setline(line('.'), line) >>> execute "normal! o" >>> if line is lines[-1] >>>

Re: Testing for last item in a list

2010-11-14 Thread Jürgen Krämer
Hi, Tim Johnson wrote: > * ZyX [101112 12:17]: >> >> for line in lines >> execute "normal! i".line >> " " May be replaced with >> " call setline(line('.'), line) >> execute "normal! o" >> if line is lines[-1] >> " do something >> en

Re: Testing for last item in a list

2010-11-13 Thread Tim Chase
On 11/12/2010 10:04 PM, ZyX wrote: Just as an alternative, you can slice lists like you do in Python: for line in lines[:-2] ... endfor Just for clarifying: in python [N:M] slice takes everything from N'th item to M'th, excluding M'th. In vim M'th item is included and it does no

Re: Testing for last item in a list

2010-11-12 Thread ZyX
Reply to message «Re: Testing for last item in a list», sent 02:57:30 13 November 2010, Saturday by Tim Chase: > Just as an alternative, you can slice lists like you do in Python: > >for line in lines[:-2] > ... >endfor > > will execute over all but th

Re: Testing for last item in a list

2010-11-12 Thread Tim Johnson
* Tony Mechelynck [101112 14:19]: > > That can still be simplified: > > for line in lines > exe 'norm! i' . line > if line isnot lines[-1] " cool! 'isnot' is new to me > norm! o > endif > endfor Thanks for the ti

Re: Testing for last item in a list

2010-11-12 Thread Tim Chase
On 11/12/2010 02:50 PM, Tim Johnson wrote: Using vim 7.2 huge version on ubuntu 10.04 In the following vimscript: "" begin code for line in lines execute "norm! i". line execute 'norm! o' endfor "" end code How may I check `line' to see if it is the

Re: Testing for last item in a list

2010-11-12 Thread Tony Mechelynck
On 12/11/10 22:42, Tim Johnson wrote: * ZyX [101112 12:17]: for line in lines execute "normal! i".line " " May be replaced with " call setline(line('.'), line) execute "normal! o" if line is lines[-1] " do something endif

Re: Testing for last item in a list

2010-11-12 Thread Tim Johnson
* ZyX [101112 12:17]: > > for line in lines > execute "normal! i".line > " " May be replaced with > " call setline(line('.'), line) > execute "normal! o" > if line is lines[-1] > " do something > endif > endfor Hi ZyX: I have bee

Re: Testing for last item in a list

2010-11-12 Thread ZyX
Reply to message «Testing for last item in a list», sent 23:50:19 12 November 2010, Friday by Tim Johnson: > Using vim 7.2 huge version on ubuntu 10.04 > In the following vimscript: > "" begin code > for line in lines > execute "norm! i". li

Testing for last item in a list

2010-11-12 Thread Tim Johnson
Using vim 7.2 huge version on ubuntu 10.04 In the following vimscript: "" begin code for line in lines execute "norm! i". line execute 'norm! o' endfor "" end code How may I check `line' to see if it is the last item in list `lines'? :) Probably :h