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

[vim73] easy way to purge 'persistence undo'?

Expand Messages
  • SungHyun Nam
    Hello, With vim-7.2, I did :e to purge undo history to start new edit session (?). With vim-7.3 (+ undofile ): I guess I could remove a undofile and run
    Message 1 of 10 , Jun 3, 2010
    • 0 Attachment
      Hello,

      With vim-7.2, I did ':e' to purge undo history to start new
      'edit session'(?).

      With vim-7.3 (+ 'undofile'):
      I guess I could remove a undofile and run ':e' to do this. Maybe
      I can make a mapping with some vim script, but...

      Is there any easy way to purge 'persistence undo' history?

      Thanks,
      namsh

      --
      You received this message from the "vim_dev" 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
    • Christian Brabandt
      Hi SungHyun! ... Try setting ul=-1 regards, Christian -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text
      Message 2 of 10 , Jun 3, 2010
      • 0 Attachment
        Hi SungHyun!

        On Do, 03 Jun 2010, SungHyun Nam wrote:

        > With vim-7.3 (+ 'undofile'):
        > I guess I could remove a undofile and run ':e' to do this. Maybe
        > I can make a mapping with some vim script, but...
        >
        > Is there any easy way to purge 'persistence undo' history?

        Try setting ul=-1

        regards,
        Christian

        --
        You received this message from the "vim_dev" 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
      • Dominique Pellé
        ... undolevels=4000 ... And the undo history was *not* purged. Undo history is only purged if I edit something in between the 2 ... .. edit something... ...
        Message 3 of 10 , Jun 3, 2010
        • 0 Attachment
          Christian Brabandt wrote:

          > Hi SungHyun!
          >
          > On Do, 03 Jun 2010, SungHyun Nam wrote:
          >
          >> With vim-7.3 (+ 'undofile'):
          >> I guess I could remove a undofile and run ':e' to do this.  Maybe
          >> I can make a mapping with some vim script, but...
          >>
          >> Is there any easy way to purge 'persistence undo' history?
          >
          > Try setting ul=-1

          I tried this:

          :set undolevels?
          undolevels=4000

          :set undolevels=-1
          :set undolevels=4000

          And the undo history was *not* purged. Undo history is
          only purged if I edit something in between the 2
          ":set undolevels=...":

          :set undolevels=-1
          .. edit something...
          :set undolevels=4000
          (undo history is now purged)

          I'm not sure how useful it is to be able to purge undo history anyway.
          I don't think I would need to do that. What I would find more
          useful, when performing multiple undos with persistent-undo, is to
          display a message such as:

          "undo reached state where file was last read/written"

          ... so that user is warned when doing multiple undos that it can
          go back in time earlier than when file was last read/written if he
          continues to undo.

          I see an item added recently on the todo list which would also be useful:

          - undofile: keep markers where the file was written/read, so that it's easy to
          go back to a saved version of the file ":earlier 1file"?

          Cheers
          -- Dominique

          --
          You received this message from the "vim_dev" 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
        • SungHyun Nam
          ... Well, it might be just my editing style. When I edit a C source and compile (and test), I purged the undo history (and maybe checkin to GIT repo). And
          Message 4 of 10 , Jun 3, 2010
          • 0 Attachment
            Dominique Pellé wrote:
            > Christian Brabandt wrote:
            >
            >> Hi SungHyun!
            >>
            >> On Do, 03 Jun 2010, SungHyun Nam wrote:
            >>
            >>> With vim-7.3 (+ 'undofile'):
            >>> I guess I could remove a undofile and run ':e' to do this. Maybe
            >>> I can make a mapping with some vim script, but...
            >>>
            >>> Is there any easy way to purge 'persistence undo' history?
            >>
            >> Try setting ul=-1
            >
            > I tried this:
            >
            > :set undolevels?
            > undolevels=4000
            >
            > :set undolevels=-1
            > :set undolevels=4000
            >
            > And the undo history was *not* purged. Undo history is
            > only purged if I edit something in between the 2
            > ":set undolevels=...":
            >
            > :set undolevels=-1
            > .. edit something...
            > :set undolevels=4000
            > (undo history is now purged)
            >
            > I'm not sure how useful it is to be able to purge undo history anyway.
            > I don't think I would need to do that. What I would find more
            > useful, when performing multiple undos with persistent-undo, is to
            > display a message such as:
            >
            > "undo reached state where file was last read/written"
            >
            > ... so that user is warned when doing multiple undos that it can
            > go back in time earlier than when file was last read/written if he
            > continues to undo.

            Well, it might be just my editing style. When I edit a C
            source and compile (and test), I purged the undo history (and
            maybe checkin to GIT repo). And edit again, if something is
            wrong, I just pressed 'u' until I return to purged state. So to
            me, even the warning message is not perfect, because I want to go
            back fast (don't want to check message while I press 'u').

            And I made a function, it works for me.

            func! util#purgeUndoHistory()
            let file = undofile(expand('%:p'))
            if filereadable(file)
            let oldundofile = &l:undofile
            setl noundofile
            silent! exec "!rm -f ".file
            e
            let &l:undofile = oldundofile
            endif
            endfunc

            > I see an item added recently on the todo list which would also be useful:
            >
            > - undofile: keep markers where the file was written/read, so that it's easy to
            > go back to a saved version of the file ":earlier 1file"?
            >
            > Cheers
            > -- Dominique
            >

            Thanks,
            namsh

            --
            You received this message from the "vim_dev" 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
          • SungHyun Nam
            ... No, it did NOT work. :-( Edit and save a file.c , and... $ vim file.c ... And if I type u , vim displays: Already at oldest change But, when I exit VIM
            Message 5 of 10 , Jun 3, 2010
            • 0 Attachment
              SungHyun Nam wrote:
              > Dominique Pellé wrote:
              >> Christian Brabandt wrote:
              >>> On Do, 03 Jun 2010, SungHyun Nam wrote:
              >>>
              >>>> With vim-7.3 (+ 'undofile'):
              >>>> I guess I could remove a undofile and run ':e' to do this. Maybe
              >>>> I can make a mapping with some vim script, but...
              >>>>
              >>>> Is there any easy way to purge 'persistence undo' history?
              >
              > And I made a function, it works for me.
              >
              > func! util#purgeUndoHistory()
              > let file = undofile(expand('%:p'))
              > if filereadable(file)
              > let oldundofile = &l:undofile
              > setl noundofile
              > silent! exec "!rm -f ".file
              > e
              > let &l:undofile = oldundofile
              > endif
              > endfunc

              No, it did NOT work. :-(
              Edit and save a 'file.c', and...
              $ vim file.c
              :call util#purgeUndoHistory()
              And if I type 'u', vim displays:
              Already at oldest change

              But, when I exit VIM and open the file.c again, 'u' works again.

              And I found the undofile was not removed. The exec line should be
              changed to:
              silent! exec "!rm -f ".escape(file, '%')

              Thanks,
              namsh

              --
              You received this message from the "vim_dev" 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
            • Ben Fritz
              ... I would also need such a feature. I will often either hold down u or use :earlier 24h or whatever, to return to the state of the buffer when I started
              Message 6 of 10 , Jun 4, 2010
              • 0 Attachment
                On Jun 3, 1:48 pm, Dominique Pellé <dominique.pe...@...> wrote:
                >
                > I'm not sure how useful it is to be able to purge undo history anyway.
                > I don't think I would need to do that.  What I would find more
                > useful, when performing multiple undos with persistent-undo, is to
                > display a message such as:
                >
                > "undo reached state where file was last read/written"
                >
                > ... so that user is warned when doing multiple undos that it can
                > go back in time earlier than when file was last read/written if he
                > continues to undo.
                >
                > I see an item added recently on the todo list which would also be useful:
                >
                > - undofile: keep markers where the file was written/read, so that it's easy to
                >   go back to a saved version of the file  ":earlier 1file"?
                >

                I would also need such a feature. I will often either hold down 'u' or
                use :earlier 24h or whatever, to return to the state of the buffer
                when I started editing.

                I do think that purging the undo history could be useful in some
                situations. If it is complicated to do (using a function as shown in
                this thread), we should probably put an example of how to do it in
                the :help or add a command to do it.

                --
                You received this message from the "vim_dev" 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
              • Ingo Karkat
                ... Though some may object that this makes Vim further encroach on the territory of a proper Revision Control System, I would find such a movement along saved
                Message 7 of 10 , Jun 4, 2010
                • 0 Attachment
                  On 03-Jun-2010 20:48, Dominique Pellé wrote:
                  > I see an item added recently on the todo list which would also be useful:
                  >
                  > - undofile: keep markers where the file was written/read, so that it's easy to
                  > go back to a saved version of the file ":earlier 1file"?

                  Though some may object that this makes Vim further encroach on the territory of
                  a proper Revision Control System, I would find such a movement along saved file
                  versions very useful. So far, I've been using my writebackup.vim plugin [1] for
                  such short-term temporary versions. +1 from me for :earlier 1file

                  I like the idea of a command to purge the undo information, if only for
                  security/privacy reasons. (Imagine you've accidentally pasted your credit card
                  info into a Vim buffer; you don't want to have that persisted to disk.)

                  -- regards, ingo

                  [1] http://www.vim.org/scripts/script.php?script_id=1828

                  --
                  You received this message from the "vim_dev" 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
                • Ben Fritz
                  ... I only recently started using undo branches, thanks to my discovery of the histwin plugin: http://www.vim.org/scripts/script.php?script_id=2932 With
                  Message 8 of 10 , Jun 4, 2010
                  • 0 Attachment
                    On Jun 4, 2:07 pm, Ingo Karkat <sw...@...> wrote:
                    > On 03-Jun-2010 20:48, Dominique Pell wrote:
                    >
                    > > I see an item added recently on the todo list which would also be useful:
                    >
                    > > - undofile: keep markers where the file was written/read, so that it's easy to
                    > >    go back to a saved version of the file  ":earlier 1file"?
                    >
                    > Though some may object that this makes Vim further encroach on the territory of
                    > a proper Revision Control System, I would find such a movement along saved file
                    > versions very useful. So far, I've been using my writebackup.vim plugin [1] for
                    > such short-term temporary versions. +1 from me for :earlier 1file
                    >

                    I only recently started using undo branches, thanks to my discovery of
                    the histwin plugin:

                    http://www.vim.org/scripts/script.php?script_id=2932

                    With :earlier 1file being available, which would probably involve
                    appropriate (parseable) markers, I imagine this plugin could readily
                    be expanded to show these file tags, giving you even more information
                    to help determine what state the times on the branches actually
                    correspond to.

                    --
                    You received this message from the "vim_dev" 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
                  • Dominique Pellé
                    ... I find the undo branches very nice but also hard to use in practice. I tend to get lost where I am in the tree when using :undo or :earlier commands.
                    Message 9 of 10 , Jun 5, 2010
                    • 0 Attachment
                      Ben Fritz wrote:

                      > I only recently started using undo branches, thanks to my discovery of
                      > the histwin plugin:
                      >
                      > http://www.vim.org/scripts/script.php?script_id=2932
                      >
                      > With :earlier 1file being available, which would probably involve
                      > appropriate (parseable) markers, I imagine this plugin could readily
                      > be expanded to show these file tags, giving you even more information
                      > to help determine what state the times on the branches actually
                      > correspond to.

                      I find the undo branches very nice but also hard to use in practice.
                      I tend to get lost where I am in the tree when using :undo or :earlier
                      commands. Currently, the ":undolist" command only shows something
                      like this:

                      :undolist
                      number changes time
                      1 15 08:53:07
                      5 18 08:53:20
                      7 14 08:53:29

                      Would it be possible to draw the structure of the undo tree?
                      What about the following mock up (use a fixed size font to properly
                      view the ASCII art):

                      :undolist
                      number changes time
                      1 15 08:53:07 <--3--o-------------12-->
                      5 18 08:53:20 \--1--S-------14-->
                      7 14 08:53:29 \--8--*--2-->


                      Where:
                      < ... is a root node in the tree. There is generally only 1 root node
                      as in above example. However, because of limited undo levels,
                      there can also be more than root node.
                      o ... is a node in the undo tree from which multiple sub-branches start.
                      \ ... is the start of a sub-branch.
                      > ... is a leaf node in the undo tree.
                      S ... is the tag of node where file was last (S)aved.
                      * ... is the current position in the undo tree. It is often located on
                      a leaf. However, when using :undo or :earlier commands, it may not
                      be located on a leaf. In above example, user has undone 2 changes
                      from the leaf in last branch so * is not located on a leaf.

                      The numbers represent the number of intermediate changes between
                      nodes o \ > S * in undo tree.

                      I realize that drawing the undo tree may be tricky when the undo tree
                      becomes large: it may then not fit on the width of the screen. In that
                      case, it could be truncated.

                      It would make the undo tree structure more intuitive.
                      What do you think?

                      -- Dominique

                      --
                      You received this message from the "vim_dev" 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
                    • Christian Brabandt
                      Hi Ingo! ... How about something like this: if has( persistent_undo ) com! DeleteUndoFile :call delete(undofile(expand( % )))|echohl WarningMsg|echo Undofile
                      Message 10 of 10 , Jun 5, 2010
                      • 0 Attachment
                        Hi Ingo!

                        On Fr, 04 Jun 2010, Ingo Karkat wrote:

                        > I like the idea of a command to purge the undo information, if only for
                        > security/privacy reasons. (Imagine you've accidentally pasted your credit
                        > card info into a Vim buffer; you don't want to have that persisted to
                        > disk.)

                        How about something like this:

                        if has('persistent_undo')
                        com! DeleteUndoFile :call delete(undofile(expand("%")))|echohl WarningMsg|echo "Undofile " . undofile(expand("%")) . " deleted!" | echohl Normal
                        endif

                        BTW: if I set ul=-1 and write the file, I also loose my undo history.
                        But as this is a global option, it will also affect all open buffers.

                        regards,
                        Christian

                        --
                        You received this message from the "vim_dev" 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.