thanks a lot. It is all clear now --Rudy
On Jul 21, 2:37 pm, Christian Brabandt <[email protected]> wrote: > Hi rudy_b! > > (please, don't top poste. I am fixing quotation) > > On Mi, 21 Jul 2010, rudy_b wrote: > > > > > On Jul 21, 10:58 am, Christian Brabandt <[email protected]> wrote: > > > :exe '%s/' join(map(range(100,line('$'),100), '''\%'' . v:val. "l$"'), > > > '\|') '/ (CHECKED)' > > Thank you all for your replies. > > they all made sense. > [...] > > your command just works fine. Can you briefly break down what each > > portion does? > > It basically builds up a dynamic substitution command and executes it. > > :exe " everything following is an expression that needs to be > executed > '%s/' " start a substitution (as we are evaluating an expression, > we need to return it as a string) > join(...,'\|') " Take the list given as first argument and join it > to a string by putting '\|' between each item (which > means OR as Regular expression, see :h /\|) > > map(..., '''\%'' . v:val. "l$"') > " Take the list, given as first argument and for each item, put > \% before it and l$ after it > > range(100,...,100) " Create a list of numbers, starting at 100, > walk in steps of hundred and go up at most until > > line('$') " numbers, which returns the last line number in > the buffer > > So what this does, it builds a pattern, that consists of every 100th line > number, that are joined by a logical OR. E.g. if you file has 350 lines, > this will built a regular expression that looks like this > /\%100l$\|\%200l$\|\%300l$ > Which means the end of each given line number. See :h /\%l for the > meaning of that atom. > > And after that , we need to append the replacement part which in this > case is simply: > > '/ (CHECKED)' " Append the String (Checked) > > So in the end, this runs > :%s/\%100l$\|\%200l$\|\%300l$/ (CHECKED) > > See also the help at > :h :exe > :h map() > :h range() > :h line() > :h /\| > :h /\%l > :h /$ > :h Lists > > for details. > > regards, > Christian -- 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
