Loading ...
Sorry, an error occurred while loading the content.

68590Re: hiding lines

Expand Messages
  • Gary Johnson
    May 4, 2006
    • 0 Attachment
      On 2006-05-04, Jack Donohue <jmdonohue@...> wrote:
      > > :v (and :g) made my day..!
      >
      > Yes, I use this a lot if I just want to filter out a set of lines, or see
      > only lines containing some text (like the old XEDIT command). But what I'd
      > really like to to is continue editing in this view and not lose all the
      > hidden lines, more like folding. I expect folding can do this, but I've
      > never gotten it to work and it seems pretty cumbersome. I'm looking for a
      > simple solution involving maybe a couple of command I can make a map for.
      >
      > I guess I'm looking for a g or v command that folds the lines instead of
      > actually deleting them.

      The basic technique of using folding for this is this:

      set foldmethod=expr
      set foldexpr=getline(v:lnum)=~'text to be folded'

      To close all the folds, you can

      set foldlevel=0

      but I usually use zM to close all folds and zR to open all folds.

      You could wrap that in a mapping and maybe a function to make it
      easier to use. I usually type it out once, then use the command
      line history and editing features to modify the pattern as needed.

      See

      :help fold-expr

      HTH,
      Gary

      --
      Gary Johnson | Agilent Technologies
      garyjohn@... | Wireless Division
      | Spokane, Washington, USA
    • Show all 26 messages in this topic