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

Exasperated with folding

Expand Messages
  • Eric Weir
    I have a file -- my journal -- in which I ve been trying to figure out how manual folding works, and how to get it to work for me in a way that s reasonably
    Message 1 of 4 , Jun 16, 2011
    • 0 Attachment
      I have a file -- my journal -- in which I've been trying to figure out how manual folding works, and how to get it to work for me in a way that's reasonably close to what I want to accomplish.

      What it would like to do would be to collapse each daily entry to a single line showing only the date and the day, which is the first line of the entry, and then to be able to reopen the file with the folds displayed as saved. With the following commands in my .vimrc I've been able to accomplish the latter

      autocmd BufWinLeave *.txt mkview
      autocmd BufWinEnter *.txt silent loadview

      The problem is that when the file opens the folds are not as I defined them. The beginning and the end of folds are in different locations than the ones I used in defining the fold. E.g., one fold will pick up a line or two from a succeeding fold.

      Originally I was defining folds on a selection established using V. Then I tried using just v and making sure that the end of the fold didn't go beyond the last character of the last line. That seemed to be working for several days. Today the problem reappeared. I went back to using V to define the area of the fold and that didn't work any better than the first time. I tried putting a blank line between the end of one fold and the beginning of another. That didn't work either. So, at present, after saving and reopening the file folds seem to occur at random locations unrelated to those I used in creating them.

      Any suggestions about what might be going on, or what it is I don't understand about folding, would be very welcome.

      Thanks,
      ------------------------------------------------------------------------------------------
      Eric Weir
      Decatur, GA USA
      eeweir@...




      --
      You received this message from the "vim_mac" 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
    • Eric Weir
      ... Thanks, René. I m loath to put nonessential characters in my files. Portable and persistent is attractive, though. I ll probably give it a trial. ...
      Message 2 of 4 , Jun 17, 2011
      • 0 Attachment
        On Jun 16, 2011, at 2:02 PM, René Köcher wrote:

        > why not use markers?
        > If you use fdm=marker then you can just put '{{{' at the start of your day entry
        > and '}}}' at the end and vim will know what to do.
        >
        > This method is portable and persistent.

        Thanks, René. I'm loath to put nonessential characters in my files. "Portable and persistent" is attractive, though.

        I'll probably give it a trial.

        ------------------------------------------------------------------------------------------
        Eric Weir
        Decatur, GA USA
        eeweir@...




        --
        You received this message from the "vim_mac" 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
      • Eric Weir
        ... Thanks, Steve. I ll have to give the first a try to understand what it will do, and whether it will give me, or help me get, what I want. René also
        Message 3 of 4 , Jun 17, 2011
        • 0 Attachment
          On Jun 16, 2011, at 2:51 PM, Steve Hall wrote:

          > It might be this simple:
          >
          > set viewoptions+=cursor,folds
          >
          > This will recall cursor location to the last place of edit and
          > remember the fold state.
          >
          > I also like to use markers in files where I'm forcing folds at
          > specific locations:

          Thanks, Steve. I'll have to give the first a try to understand what it will do, and whether it will give me, or help me get, what I want.

          René also suggested markers. While I'm reluctant to put non-relevant characters in my files, I may give it a try.

          ------------------------------------------------------------------------------------------
          Eric Weir
          Decatur, GA USA
          eeweir@...




          --
          You received this message from the "vim_mac" 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
        • Eric Weir
          ... Since this seemed like the simplest solution I tried it first. I used V and } to select the fold region, and had two blank lines between each entry. Still
          Message 4 of 4 , Jun 17, 2011
          • 0 Attachment
            On Jun 16, 2011, at 2:51 PM, Steve Hall wrote:

            > It might be this simple:
            >
            > set viewoptions+=cursor,folds
            >
            > This will recall cursor location to the last place of edit and
            > remember the fold state.

            Since this seemed like the simplest solution I tried it first. I used V and } to select the fold region, and had two blank lines between each entry. Still have the problem. At least a version of it.

            The last paragraph of my last entry refuses to be included in the fold, no matter what I do to try to get it in. This paragraph was added to the entry after the preceding paragraphs, and after a save and reload of the file. I notice also that before saving there are two dashes to the left of fold line before I save and three after reloading after a save. [I am unclear about the meaning of the dashes. I forget whether it indicates that that fold is contained in another fold, or that it contains another fold.]

            I've tried doing zD on the fold followed by a zD on the entire entry, including the last paragraph, assuming that will eliminate all folds in the entry. Then I redo the fold using V and } to select the region to establish a single new fold including the last paragraph. When I save and reload, the last paragraph is again missing from the fold.

            ------------------------------------------------------------------------------------------
            Eric Weir
            Decatur, GA USA
            eeweir@...




            --
            You received this message from the "vim_mac" 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
          Your message has been successfully submitted and would be delivered to recipients shortly.