Hi, Jürgen Krämer schrieb: > > Tim Johnson wrote: >> * ZyX <zyx....@gmail.com> [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 been enlightened. >> "This works >> for line in lines >> execute "norm! i". line >> if line is lines[-1] >> continue >> else >> execute 'norm! o' >> endif >> endfor > > 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 > the second section below ":help E693"). So this code does not check if the > last line is processed, but you if it's a line that's identical to the last > line. For example,
minor clarification: "a line whose content is identical to that of the last line." > > let lines = [ '1', '2', '3', '4', '1', '2', '3', '4' ] > for line in lines > if line is lines[-1] > echo line . ' SKIP' > else > echo line . ' OK' > endif > endfor > > prints > > 1 OK > 2 OK > 3 OK > 4 SKIP > 1 OK > 2 OK > 3 OK > 4 SKIP > > Regards, > Jürgen > > -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin) -- You received this message from the "vim_use" 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