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

Svar: Folding

Expand Messages
  • Dan Michael
    ... If I got your question right, it s about Vim in general, not MacVim-specific, and so better suited for another list like vim_use, not vim_mac, but here we
    Message 1 of 15 , Jun 2, 2011
    • 0 Attachment
      onsdag 1. juni 2011 kl. 15:37:08 UTC+2 skrev Eric Weir følgende:

      I'm a Vim novice, and a writer not a programmer. I've perused the responses to questions about folding in the Vim FAQ. It's largely Greek to me. I have a couple questions: I understand folds can be indented. Is it possible to get Vim to wrap words to the indent column? Is there a way I can get folds to persist across a save and reload?

      If I got your question right, it's about Vim in general, not MacVim-specific, and so better suited for another list like vim_use, not vim_mac, but here we go. My personal favorite when it comes to manual, persistent folding is to use the marker foldmethod (:set foldmethod=marker). You may add this as a modeline (see :help modeline) on the first line of the file (vi: foldmethod=marker). Then write your file like this:

      Header for section 1 {{{
          Some header for section 1.1 {{{
               lorem ipsum
               ...
          }}}
          ...
      }}}

      But of course you may not like to have the "{{{" and "}}}"s in your file, and then there are other foldmethods. Folds can be set using invisible markers and saved (to an external file) using mkview (:help mkview). That makes the file less transferable, since you may move the file to another computer and not get the folds along, but that may or may not be a problem for you. See for instance this page for more help:

      http://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun

      Word-wrapping: See :h wrap, :h textwidth

      - Dan Michael

      --
      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, Dan. Both this method and the one using invisible markers and mkview are intriguing. I ll read up on them. Will probably have further questions
      Message 2 of 15 , Jun 2, 2011
      • 0 Attachment

        On Jun 2, 2011, at 6:56 AM, Dan Michael wrote:

        onsdag 1. juni 2011 kl. 15:37:08 UTC+2 skrev Eric Weir følgende:

        I'm a Vim novice, and a writer not a programmer. I've perused the responses to questions about folding in the Vim FAQ. It's largely Greek to me. I have a couple questions: I understand folds can be indented. Is it possible to get Vim to wrap words to the indent column? Is there a way I can get folds to persist across a save and reload?

        .... My personal favorite when it comes to manual, persistent folding is to use the marker foldmethod (:set foldmethod=marker). You may add this as a modeline (see :help modeline) on the first line of the file (vi: foldmethod=marker)....

        Thanks, Dan. Both this method and the one using invisible markers and mkview are intriguing. I'll read up on them. Will probably have further questions after that.


        Word-wrapping: See :h wrap, :h textwidth

        And thanks for both of these. 

        It appears that what I wanted in the way of word wrapping is [1] not possible except by fiddling with the code of the executable and [2] not essential for the purpose I had in mind, i.e., making all text within a certain range of a given line "disappear under" that line, as a subtopic would under a topic in an outline. I can get what I want, minus indentation, by folding on all the other lines first, then folding on all the lines, indluding the first.

        ------------------------------------------------------------------------------------------
        Eric Weir
        Decatur, GA  USA




        --
        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
        ... I though this from the above is going to work for me, Dan. But why do something manually when you can do it automatically? To see to it that Vim saves and
        Message 3 of 15 , Jun 2, 2011
        • 0 Attachment

          On Jun 2, 2011, at 6:56 AM, Dan Michael wrote:

          http://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun

          I though this from the above is going to work for me, Dan. 

          But why do something manually when you can do it automatically? To see to it that Vim saves and restores folds when a file is closed and re-opened, add these two lines to your ~/.vimrc:

          au BufWinLeave * mkview
          au BufWinEnter * silent loadview
          

          Now, each time you close a file, its fold state will be saved and reloaded when you reopen the file in Vim.

          After doing that, quitting and restarting Vim, then saving a folded file and reopening it, it opened unfolded. My guess is that something is taken for granted in the suggestion above that in my case should not be taken for granted. What am I missing?

          Thanks,
          ------------------------------------------------------------------------------------------
          Eric Weir
          Decatur, GA  USA




          --
          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
          ... My mistake. On my first try I hadn t saved the folded file since inserting those lines in my .vimrc. After doing that the file does open folded. There are
          Message 4 of 15 , Jun 2, 2011
          • 0 Attachment

            On Jun 2, 2011, at 10:39 AM, Eric Weir wrote:

            After doing that, quitting and restarting Vim, then saving a folded file and reopening it, it opened unfolded.

            My mistake. On my first try I hadn't saved the folded file since inserting those lines in my .vimrc. After doing that the file does open folded. There are a couple of problems, though:

            After inserting these lines when starting Vim or creating a new tab I get this error message:

            Error detected while processing BufWinEnter Auto commands for "*":
            E32: No file name   

            And when I open a file, I get the following message:

            Error detected while processing BufWinLeave Auto commands for "*":

            After that, when i hit <return> the file opens folded. 

            I suspect something was assumed in the suggestion of this option that in my case should not be assumed. What am i missing?

            Thanks,
            ------------------------------------------------------------------------------------------
            Eric Weir
            Decatur, GA  USA




            --
            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
            ... Continue to get the first error message, but not the second. However, when a file saved with ten folded lines is saved and reopened, it reopens with only
            Message 5 of 15 , Jun 3, 2011
            • 0 Attachment

              On Jun 2, 2011, at 10:55 AM, Eric Weir wrote:

              After inserting these lines when starting Vim or creating a new tab I get this error message:

              Error detected while processing BufWinEnter Auto commands for "*":
              E32: No file name   

              And when I open a file, I get the following message:

              Error detected while processing BufWinLeave Auto commands for "*":

              After that, when i hit <return> the file opens folded.

              Continue to get the first error message, but not the second. However, when a file saved with ten folded lines is saved and reopened, it reopens with only two lines folded.

              If anyone can suggest what's going on it would be appreciated.

              Thanks,
              ------------------------------------------------------------------------------------------
              Eric Weir
              Decatur, GA  USA




              --
              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
            • Dan Michael
              ... This is because vim naively tries to load the view for an empty buffer, but of course no saved view exists for the empty buffer. The same happens when you
              Message 6 of 15 , Jun 4, 2011
              • 0 Attachment
                fredag 3. juni 2011 kl. 15:37:57 UTC+2 skrev Eric Weir følgende:

                On Jun 2, 2011, at 10:55 AM, Eric Weir wrote:

                After inserting these lines when starting Vim or creating a new tab I get this error message:

                Error detected while processing BufWinEnter Auto commands for "*":
                E32: No file name   

                This is because vim naively tries to load the view for an empty buffer, but of course no saved view exists for the empty buffer. The same happens when you open a help page. There is no saved view for the help pages, so you will get an error. One simple solution is to use "silent!" instead of "silent". This will silence any error message. My preferred solution is to instead to save views only for files of certain extensions (since mkview saves a lot of things, not just folds, and sometimes you just don't want it all saved). So, for instance,

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

                And you could also use

                autocmd BufWinLeave *.* mkview
                autocmd BufWinEnter *.* silent loadview
                 
                for it to work with all files with a file extension.

                And when I open a file, I get the following message:

                Error detected while processing BufWinLeave Auto commands for "*":

                After that, when i hit <return> the file opens folded.

                Try disabling all plugins and clean your .vimrc file, and see if it still happens. You may also have to clean your ~/.vim/views folder, which is where the views are saved (but then you will loose the folds). 

                Then please see :h viewoptions . As you see, a lot of things about the state of the file are saved with mkview, not only folds. It may be a very good idea to only save the things you need, like e.g. :set viewoptions=folds,cursor 

                Good luck further! But please try to avoid quadruple-posting next time.

                – Dan Michael

                --
                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
              • Devric
                Hey Eric Rather spend so many times writing your own indenting, have you tried org mode for vim plugin? search org mode in vim scripts, and should have some
                Message 7 of 15 , Jun 4, 2011
                • 0 Attachment
                  Hey Eric

                  Rather spend so many times writing your own indenting, have you tried
                  org mode for vim plugin? search org mode in vim scripts, and should
                  have some videos to show what it is.
                  alternative you can use emacs org mode, even though emacs org mode is
                  so much more powerful but i still love vim more, cos is much more
                  intuitive than emacs,

                  using org mode plugin for vim, it has really simple indent method such
                  as using the " * " symbol to create heading-> sub-heading, unlimited

                  * 1
                  ** 2
                  *** 2.1
                  **** 2.1.1
                  **** 2,1.2
                  ** 3
                  *** 3.1

                  and other really amazing functions such as GTD, calendar, tagging blah
                  blah you can find them in the videos since i mostly just use the
                  indentation to record notes

                  i don't think it remembers the state which line is folded which is
                  not, its all folded when opening the file, but it is quite simple,
                  just use "tab" key than it expands and minimizes, much easier than
                  zR... even you add a shortcut, it still doesn't beat "tab"

                  if you also like to use the @tags , its good that you also get the
                  plugin of compview, this gives you a small slide down buffer letting
                  you see all your search results, when you highlight the line in that
                  small buffer, you will jump your view in your working buffer to that
                  line. to trigger it use the leader key than v eg: \v

                  have a go at it, i think you should love them as a writer. invest
                  sometime in org mode plugin for vim, it saves you the headache of
                  making one your own.


                  On Jun 1, 11:37 pm, Eric Weir <eew...@...> wrote:
                  > I'm a Vim novice, and a writer not a programmer. I've perused the responses to questions about folding in the Vim FAQ. It's largely Greek to me. I have a couple questions: I understand folds can be indented. Is it possible to get Vim to wrap words to the indent column? Is there a way I can get folds to persist across a save and reload?
                  >
                  > Thanks,
                  > ------------------------------------------------------------------------------------------
                  > Eric Weir
                  > Decatur, GA  USA
                  > eew...@...

                  --
                  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, Dan. I gave this one a try. Now I don t get either of the error messages. ... Does this refer to multiple copies of the same post or multiple
                  Message 8 of 15 , Jun 4, 2011
                  • 0 Attachment

                    On Jun 4, 2011, at 9:42 AM, Dan Michael wrote:

                    fredag 3. juni 2011 kl. 15:37:57 UTC+2 skrev Eric Weir følgende:

                    On Jun 2, 2011, at 10:55 AM, Eric Weir wrote:

                    After inserting these lines when starting Vim or creating a new tab I get this error message:

                    Error detected while processing BufWinEnter Auto commands for "*":
                    E32: No file name   

                    This is because vim naively tries to load the view for an empty buffer, but of course no saved view exists for the empty buffer. The same happens when you open a help page. There is no saved view for the help pages, so you will get an error. One simple solution is to use "silent!" instead of "silent". This will silence any error message. My preferred solution is to instead to save views only for files of certain extensions (since mkview saves a lot of things, not just folds, and sometimes you just don't want it all saved). So, for instance,

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

                    Thanks, Dan. I gave this one a try. Now I don't get either of the error messages.

                    Good luck further! But please try to avoid quadruple-posting next time.

                    Does this refer to multiple copies of the same post or multiple responses to a response before receiving a response?

                    If the former, it shouldn't happen anymore. For a while Apple Mail was hanging up on send, and several times that resulted in multiple copies getting sent when the message was finally sent.

                    If the second, I didn't realize that that was discouraged.

                    ------------------------------------------------------------------------------------------
                    Eric Weir
                    Decatur, GA  USA




                    --
                    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, Devric. Never heard of org mode. As you describe it, sounds very interesting. I ll go looking for it. ... I was recently given a solution for this.
                    Message 9 of 15 , Jun 4, 2011
                    • 0 Attachment

                      On Jun 4, 2011, at 1:21 PM, Devric wrote:

                      Rather spend so many times writing your own indenting, have you tried
                      org mode for vim plugin? search org mode in vim scripts, and should
                      have some videos to show what it is.



                      using org mode plugin for vim, it has really simple indent method such
                      as using the " * " symbol to create heading-> sub-heading, unlimited

                      * 1
                      ** 2
                      *** 2.1
                      **** 2.1.1
                      **** 2,1.2
                      ** 3
                      *** 3.1

                      and other really amazing functions such as GTD, calendar, tagging blah
                      blah you can find them in the videos since i mostly just use the
                      indentation to record notes

                      Thanks, Devric. Never heard of org mode. As you describe it, sounds very interesting. I'll go looking for it. 

                      i don't think it remembers the state which line is folded which is
                      not, its all folded when opening the file....

                      I was recently given a solution for this. Any one of these:

                      au BufWinLeave * mkview
                      au BufWinEnter * silent loadview

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

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


                      have a go at it, i think you should love them as a writer.  invest
                      sometime in org mode plugin for vim, it saves you the headache of
                      making one your own.

                      I am definitely intrigued.

                      ------------------------------------------------------------------------------------------
                      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
                      ... Curious, Devric. I ve been checking out the Vim Organizer videos. I notice that when adding body text the first column is aligned with the first column of
                      Message 10 of 15 , Jun 8, 2011
                      • 0 Attachment
                        On Jun 4, 2011, at 1:21 PM, Devric wrote:

                        > using org mode plugin for vim, it has really simple indent method such
                        > as using the " * " symbol to create heading-> sub-heading, unlimited
                        >
                        > * 1
                        > ** 2
                        > *** 2.1
                        > **** 2.1.1
                        > **** 2,1.2
                        > ** 3
                        > *** 3.1

                        Curious, Devric. I've been checking out the Vim Organizer videos. I notice that when adding body text the first column is aligned with the first column of the heading. Assuming you have linebreak set so words wrap to the screen, what happens when the body text extends beyond the first line, i.e., are subsequent lines also aligned with the first column of the heading?

                        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
                      Your message has been successfully submitted and would be delivered to recipients shortly.