On 10/01/09 01:28, Philip Rhoades wrote:
> John,
>
>
> John Beckett wrote:
>> Philip Rhoades wrote:
>>> I had a large file and wanted to see only the
>>> lines that contained the search text
>> Tim has provided the answer, but here is more:
>> http://vim.wikia.com/wiki/Folding_with_Regular_Expression
>> http://vim.wikia.com/wiki/Copy_the_search_results_into_clipboard
>>
>> It would be good if someone compared Tim's version with the first of the
>> above. Please edit the wiki or reply here if the tip should be improved.
>
>
> Yes, I did find my way to this stuff after comments re Tim's post and
> have been playing with the different methods - I seem to not be able to
> get the +/- extra lines with the context displays and I get a column of
> single digit numbers down the left hand side when I remove the folds -
> but I am not confident enough to say that I am not doing something silly
> . . and that stuff is probably more than I need just at the moment anyway.
>
> Regards,
>
> Phil.

The commands given by Tim and (with slight variation) by me will fold 
away _all_ lines not containing the search text, with no context. To get 
context, you could use diff instead, as follows:

        :split
        :saveas ~/difftemp
        :%g/searchtext/d
        :wall
        :!diff -u % # >temp.diff

Then the file "temp.diff" in the current directory will display all 
lines containing the search text, with some context above and below each 
group. (Lines containing the search text have a + in the left margin, 
omitted lines are clearly set off.) Of course this requires a "diff" 
program in your PATH, which is standard on Unix but not on Windows.

Replace -u by (for instance) -U6 to get (let's say) six lines of context 
instead of the default three.


Best regards,
Tony.
-- 
For some reason, this fortune reminds everyone of Marvin Zelkowitz.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to