Wednesday, April 25, 2012

Re: :il[ist] with numeric patterns

On 25 Abr, 12:36, "John Beckett" <johnb.beck...@gmail.com> wrote:
> Andy Wokula wrote:
> > Many `:[range]' commands accept an optional count as the
> > first argument, apparently this is true for :ilist also:
>
> >      :il 3 20
>
> > finds `20' in the text.  Not sure if the count has any purpose.

Thank you! This is Interesting but tricky and not at all obvious. In
fact the help doesn't say anything about an optional count:

:[range]il[ist][!] [/]pattern[/]
Like "[I" and "]I", but search in [range] lines
(default: whole file).
See |:search-args| for [/] and [!]. {not in Vi}


> Thanks, I was going to propose :ilist to the OP but did not when
> I could not get it to work.
>
> A quick test shows you need a bang to get all numbers, including
> those in comments as documented.
>
> In a new buffer (':new') with these three lines:
> 123> 123
>
> let s = '123'
>
> using ':ilist 1 123' shows only lines 1 and 3, while
> ':ilist! 1 123' shows all three lines.
>

This is also interesting. When I checked the help for 'search-args' I
read
[!] When included, find matches in lines that are recognized as
comments.
and I stopped reading. I didn't pay any attention to the explanation
about [!] and 'comments' because I thought it would not be relevant
for a buffer with no particular file type. Now I see I was wrong,
since vim has always some notion of what a comment is according to the
settings in the 'comments' option.

Thank you everybody for the help.
PS: ":ilist! 0 123" also works. I prefer this as it makes slightly
more clear that 0 is just a dummy value.

--
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

No comments: