> Is there a way to display only the lines that match > a search pattern and hide/fold others. > Any help appreciated.
There are a number of ways to get the effect you are looking for. One might be: :set foldmethod=expr :set foldexpr=getline(v:lnum)!~'pattern' which will actually use folding to fold away any adjacent lines that don't match 'pattern'. However, if there aren't adjacent lines, the folding doesn't always show up (you see it in the fold-column if you have that showing, but it's not usually visible otherwise). You can tweak the 'foldminlines' setting and bump this back to 0 to get some visual indicator that a single line is folded: :set foldminlines=0 You could also do something like :match Comment /pattern/ which will make every line matching /pattern/ appear as if it's commented out. You can even take this a step further and make a highlighting target like hi Invisible termbg=black termfg=black and then use "Invisible" rather than "Comment". This doesn't actually fold away the lines, but it just makes your non-"hidden" lines pop out visually. Another idea would be just to exploit the powerful undo abilities of Vim and simply :g/pattern/d to delete the lines you don't want to see, and then just use "u" to undo it. (or save beforehand, delete the lines, and then re-edit the file with ":e!") Just a few ideas depending on the sort of behavior you want. HTH, -tim