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

Re: swap files reverting my work erroneously

Expand Messages
  • ZyX
    Reply to message «Re: swap files reverting my work erroneously», sent 04:27:35 02 August 2011, Tuesday ... It is false: if I choose to delete swap file (in
    Message 1 of 25 , Aug 1 8:28 PM
      Reply to message «Re: swap files reverting my work erroneously»,
      sent 04:27:35 02 August 2011, Tuesday
      by Gary Johnson:

      > will tell you that it has found a swap file, etc. Regardless of you
      > choice, Vim will use a new swap file for the current buffer, named
      > .foo.swo. That file will be deleted at the end of your Vim session
      > if you exit normally. The swap file from your previous Vim session,
      > .foo.swp, will remain. That's the one you have to delete manually.
      It is false: if I choose to delete swap file (in the vim prompt, not from shell)
      it will use .foo.swp, not .foo.swo.

      > > I think noswapfile will checked into my env repo. When you have 30+
      > > buffers open, this is not very useful to me.
      >
      > I think that is a bad idea. Vim creates swap files to protect your
      > data. They only persist after Vim has crashed, which is a good
      > thing. Once you have decided to use their contents after a crash,
      > or not, you can delete them and not be bothered with them until the
      > next time Vim crashes.
      I have swap files to prevent myself from editing one file in two vim instances
      simultaneously. Though sometimes something goes wrong and vim or the whole
      system crashes, but I never needed them to recover anything. All you need to
      have the same behavior is to train yourself to do «paused for thinking - hit
      {lhs of your mapping to :up} to save file». For me it happens even more times
      then «stopped inserting - exit insert mode».

      Original message:
      > On 2011-08-01, David Ohlemacher wrote:
      > > So once you have a swap file from a crash its there forever. That is
      > > until you delete the swp manually. And if you hit recover, your newer
      > > file contents will be wiped out by an older swap file's contents?
      >
      > It would be more correct to say that if you hit recover, the buffer
      > will be filled from the swap file instead of the file you opened.
      > Nothing has been wiped out. The contents of your file are unchanged
      > from what they were before you opened the file.
      >
      > To easily see the difference between the current file contents
      > (still on disk) and the recovered file content (in the Vim buffer),
      > use DiffOrig. See
      >
      > :help DiffOrig
      >
      > You can now choose to replace the contents of the file on disk with
      > the recovered contents from the crashed session, or conversely, you
      > can choose to replace the contents of the Vim buffer with the
      > contents of the file on disk. Your choice. And until you decide,
      > no data has been lost.
      >
      > > I assumed (word chosen carefully), that once you've recovered from a swap
      > > file, the swap would be updated to mirror the current buffer.
      >
      > The swap file in use _is_ updated to mirror the current buffer, but
      > the swap file in use is not the same one you recovered from.
      >
      > For example, if you open foo and Vim crashes, there will be a
      > .foo.swp file left in your current directory (assuming that you
      > don't put your swap files elsewhere). If you open foo again, Vim
      > will tell you that it has found a swap file, etc. Regardless of you
      > choice, Vim will use a new swap file for the current buffer, named
      > .foo.swo. That file will be deleted at the end of your Vim session
      > if you exit normally. The swap file from your previous Vim session,
      > .foo.swp, will remain. That's the one you have to delete manually.
      >
      > > I think noswapfile will checked into my env repo. When you have 30+
      > > buffers open, this is not very useful to me.
      >
      > I think that is a bad idea. Vim creates swap files to protect your
      > data. They only persist after Vim has crashed, which is a good
      > thing. Once you have decided to use their contents after a crash,
      > or not, you can delete them and not be bothered with them until the
      > next time Vim crashes.
      >
      > Regards,
      > Gary
    • Gary Johnson
      ... I stand corrected. Thanks. ... That s another good reason to use swap files. The trouble with continually saving, though, is that you lose your reference
      Message 2 of 25 , Aug 1 9:20 PM
        On 2011-08-02, ZyX wrote:
        > Reply to message «Re: swap files reverting my work erroneously»,
        > sent 04:27:35 02 August 2011, Tuesday
        > by Gary Johnson:
        >
        > > will tell you that it has found a swap file, etc. Regardless of you
        > > choice, Vim will use a new swap file for the current buffer, named
        > > .foo.swo. That file will be deleted at the end of your Vim session
        > > if you exit normally. The swap file from your previous Vim session,
        > > .foo.swp, will remain. That's the one you have to delete manually.
        > It is false: if I choose to delete swap file (in the vim prompt, not from shell)
        > it will use .foo.swp, not .foo.swo.

        I stand corrected. Thanks.

        > > > I think noswapfile will checked into my env repo. When you have 30+
        > > > buffers open, this is not very useful to me.
        > >
        > > I think that is a bad idea. Vim creates swap files to protect your
        > > data. They only persist after Vim has crashed, which is a good
        > > thing. Once you have decided to use their contents after a crash,
        > > or not, you can delete them and not be bothered with them until the
        > > next time Vim crashes.
        > I have swap files to prevent myself from editing one file in two vim instances
        > simultaneously. Though sometimes something goes wrong and vim or the whole
        > system crashes, but I never needed them to recover anything. All you need to
        > have the same behavior is to train yourself to do «paused for thinking - hit
        > {lhs of your mapping to :up} to save file». For me it happens even more times
        > then «stopped inserting - exit insert mode».

        That's another good reason to use swap files. The trouble with
        continually saving, though, is that you lose your reference for the
        changes you've made to the file since you started editing. That's
        not always important, but sometimes it's very handy. And having
        swap files means I can do that without worry.

        Regards,
        Gary

        --
        You received this message from the "vim_use" 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
      • ZyX
        Reply to message «Re: swap files reverting my work erroneously», sent 08:20:31 02 August 2011, Tuesday ... Was not this solved by persistent undo introduced
        Message 3 of 25 , Aug 1 9:38 PM
          Reply to message «Re: swap files reverting my work erroneously»,
          sent 08:20:31 02 August 2011, Tuesday
          by Gary Johnson:

          > The trouble with
          > continually saving, though, is that you lose your reference for the
          > changes you've made to the file since you started editing. That's
          > not always important, but sometimes it's very handy. And having
          > swap files means I can do that without worry.
          Was not this solved by persistent undo introduced in vim-7.3?

          Original message:
          > On 2011-08-02, ZyX wrote:
          > > Reply to message «Re: swap files reverting my work erroneously»,
          > > sent 04:27:35 02 August 2011, Tuesday
          > >
          > > by Gary Johnson:
          > > > will tell you that it has found a swap file, etc. Regardless of you
          > > > choice, Vim will use a new swap file for the current buffer, named
          > > > .foo.swo. That file will be deleted at the end of your Vim session
          > > > if you exit normally. The swap file from your previous Vim session,
          > > > .foo.swp, will remain. That's the one you have to delete manually.
          > >
          > > It is false: if I choose to delete swap file (in the vim prompt, not from
          > > shell) it will use .foo.swp, not .foo.swo.
          >
          > I stand corrected. Thanks.
          >
          > > > > I think noswapfile will checked into my env repo. When you have 30+
          > > > > buffers open, this is not very useful to me.
          > > >
          > > > I think that is a bad idea. Vim creates swap files to protect your
          > > > data. They only persist after Vim has crashed, which is a good
          > > > thing. Once you have decided to use their contents after a crash,
          > > > or not, you can delete them and not be bothered with them until the
          > > > next time Vim crashes.
          > >
          > > I have swap files to prevent myself from editing one file in two vim
          > > instances simultaneously. Though sometimes something goes wrong and vim
          > > or the whole system crashes, but I never needed them to recover
          > > anything. All you need to have the same behavior is to train yourself to
          > > do «paused for thinking - hit {lhs of your mapping to :up} to save
          > > file». For me it happens even more times then «stopped inserting - exit
          > > insert mode».
          >
          > That's another good reason to use swap files. The trouble with
          > continually saving, though, is that you lose your reference for the
          > changes you've made to the file since you started editing. That's
          > not always important, but sometimes it's very handy. And having
          > swap files means I can do that without worry.
          >
          > Regards,
          > Gary
        • Tony Mechelynck
          ... If you need a snapshot of a certain state of the disk file, take a copy. If you need successive snapshots, use numbered or dated backups, Vim supports
          Message 4 of 25 , Aug 1 10:17 PM
            On 02/08/11 06:38, ZyX wrote:
            > Reply to message «Re: swap files reverting my work erroneously»,
            > sent 08:20:31 02 August 2011, Tuesday
            > by Gary Johnson:
            >
            >> The trouble with
            >> continually saving, though, is that you lose your reference for the
            >> changes you've made to the file since you started editing. That's
            >> not always important, but sometimes it's very handy. And having
            >> swap files means I can do that without worry.
            > Was not this solved by persistent undo introduced in vim-7.3?
            >
            > Original message:
            >> On 2011-08-02, ZyX wrote:
            >>> Reply to message «Re: swap files reverting my work erroneously»,
            >>> sent 04:27:35 02 August 2011, Tuesday
            >>>
            >>> by Gary Johnson:
            >>>> will tell you that it has found a swap file, etc. Regardless of you
            >>>> choice, Vim will use a new swap file for the current buffer, named
            >>>> .foo.swo. That file will be deleted at the end of your Vim session
            >>>> if you exit normally. The swap file from your previous Vim session,
            >>>> .foo.swp, will remain. That's the one you have to delete manually.
            >>>
            >>> It is false: if I choose to delete swap file (in the vim prompt, not from
            >>> shell) it will use .foo.swp, not .foo.swo.
            >>
            >> I stand corrected. Thanks.
            >>
            >>>>> I think noswapfile will checked into my env repo. When you have 30+
            >>>>> buffers open, this is not very useful to me.
            >>>>
            >>>> I think that is a bad idea. Vim creates swap files to protect your
            >>>> data. They only persist after Vim has crashed, which is a good
            >>>> thing. Once you have decided to use their contents after a crash,
            >>>> or not, you can delete them and not be bothered with them until the
            >>>> next time Vim crashes.
            >>>
            >>> I have swap files to prevent myself from editing one file in two vim
            >>> instances simultaneously. Though sometimes something goes wrong and vim
            >>> or the whole system crashes, but I never needed them to recover
            >>> anything. All you need to have the same behavior is to train yourself to
            >>> do «paused for thinking - hit {lhs of your mapping to :up} to save
            >>> file». For me it happens even more times then «stopped inserting - exit
            >>> insert mode».
            >>
            >> That's another good reason to use swap files. The trouble with
            >> continually saving, though, is that you lose your reference for the
            >> changes you've made to the file since you started editing. That's
            >> not always important, but sometimes it's very handy. And having
            >> swap files means I can do that without worry.
            >>
            >> Regards,
            >> Gary

            If you need a snapshot of a certain state of the disk file, take a copy.
            If you need successive snapshots, use numbered or dated backups, Vim
            supports them, after a fashion: see ":help backupext".

            I'm sure I'm not the only one on these lists who started editing at a
            time (and with an editor) where such luxuries as automatically recorded
            swapfiles simply didn't exist: for us old-timers, it has become a reflex
            to save the files whenever we stop editing (even if it's just to take a
            leak), and at least once every quarter-hour.

            I have the following mappings for that:

            :map <F3> :wa|wv<CR>
            :imap <F3> <C-O>:wa|wv<CR>

            Of course, it complains if I have text in an unnamed buffer, but those
            are usually throwaways anyway.

            This way, even in case of a crash or of an AC cutoff, at most one or
            two, usually none of the 32 files which I have in various windows and
            tab pages in gvim, needs any rebuilding: everything was already saved,
            and when gvim comes back up, I can answer Delete to all (or almost all)
            of the swapfiles that it finds on restart.


            Best regards,
            Tony.
            --
            "You are old," said the youth, "as I mentioned before,
            And make errors few people could bear;
            You complain about everyone's English but yours --
            Do you really think this is quite fair?"

            "I make lots of mistakes," Father William declared,
            "But my stature these days is so great
            That no critic can hurt me -- I've got them all scared,
            And to stop me it's now far too late."

            --
            You received this message from the "vim_use" 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 Gary! ... I have been thinking lately if it would be a good idea, if Vim would only create a swap file, when it detects, that a change to the buffer has
            Message 5 of 25 , Aug 1 10:44 PM
              Hi Gary!

              On Mo, 01 Aug 2011, Gary Johnson wrote:

              > don't put your swap files elsewhere). If you open foo again, Vim
              > will tell you that it has found a swap file, etc. Regardless of you
              > choice, Vim will use a new swap file for the current buffer, named
              > .foo.swo. That file will be deleted at the end of your Vim session
              > if you exit normally. The swap file from your previous Vim session,
              > .foo.swp, will remain. That's the one you have to delete manually.

              I have been thinking lately if it would be a good idea, if Vim would
              only create a swap file, when it detects, that a change to the buffer
              has been made. But not just when viewing a file.

              That is usually what happens a lot to me. I have 1 file open and in
              another Vim instance I open the same file again only for viewing, so I
              would like to avoid the "Attention" prompt.

              On the other hand I can see, that it is certainly useful, if you start
              editing a file and immediately Vim warns you, that another Vim instance
              is already editing that file. Hm, may be a new option swaponchange or
              something?

              regards,
              Christian

              --
              You received this message from the "vim_use" 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 ZyX! ... Yes if enabled. regards, Christian -- Ein Mensch in einer fremden Stadt fragt: Wissen Sie, wo es zum Bahnhof geht? Manager: Fragen Sie nicht
              Message 6 of 25 , Aug 1 10:45 PM
                Hi ZyX!

                On Di, 02 Aug 2011, ZyX wrote:

                > by Gary Johnson:
                > > The trouble with
                > > continually saving, though, is that you lose your reference for the
                > > changes you've made to the file since you started editing. That's
                > > not always important, but sometimes it's very handy. And having
                > > swap files means I can do that without worry.
                > Was not this solved by persistent undo introduced in vim-7.3?

                Yes if enabled.

                regards,
                Christian
                --
                Ein Mensch in einer fremden Stadt fragt:
                "Wissen Sie, wo es zum Bahnhof geht?"
                Manager: "Fragen Sie nicht lange. Gehen Sie einfach los."

                --
                You received this message from the "vim_use" 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
              • George Dinwiddie
                ... I d just like to note that if you open the file in read-only mode (e.g., with view ), then no swap file is created. - George -- ... * George
                Message 7 of 25 , Aug 2 6:27 AM
                  On 8/2/11 1:44 AM, Christian Brabandt wrote:
                  > I have been thinking lately if it would be a good idea, if Vim would
                  > only create a swap file, when it detects, that a change to the buffer
                  > has been made. But not just when viewing a file.
                  >
                  > That is usually what happens a lot to me. I have 1 file open and in
                  > another Vim instance I open the same file again only for viewing, so I
                  > would like to avoid the "Attention" prompt.
                  >
                  > On the other hand I can see, that it is certainly useful, if you start
                  > editing a file and immediately Vim warns you, that another Vim instance
                  > is already editing that file. Hm, may be a new option swaponchange or
                  > something?

                  I'd just like to note that if you open the file in read-only mode (e.g.,
                  with 'view <filename>'), then no swap file is created.

                  - George

                  --
                  ----------------------------------------------------------------------
                  * George Dinwiddie * http://blog.gdinwiddie.com
                  Software Development http://www.idiacomputing.com
                  Consultant and Coach http://www.agilemaryland.org
                  ----------------------------------------------------------------------

                  --
                  You received this message from the "vim_use" 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
                • Tony Mechelynck
                  ... IIUC, opening a file read-only (e.g. with :view rather than :edit) does not create a corresponding swapfile. If you open a file with :edit (or :split or
                  Message 8 of 25 , Aug 2 6:32 AM
                    On 02/08/11 07:44, Christian Brabandt wrote:
                    > Hi Gary!
                    >
                    > On Mo, 01 Aug 2011, Gary Johnson wrote:
                    >
                    >> don't put your swap files elsewhere). If you open foo again, Vim
                    >> will tell you that it has found a swap file, etc. Regardless of you
                    >> choice, Vim will use a new swap file for the current buffer, named
                    >> .foo.swo. That file will be deleted at the end of your Vim session
                    >> if you exit normally. The swap file from your previous Vim session,
                    >> .foo.swp, will remain. That's the one you have to delete manually.
                    >
                    > I have been thinking lately if it would be a good idea, if Vim would
                    > only create a swap file, when it detects, that a change to the buffer
                    > has been made. But not just when viewing a file.
                    >
                    > That is usually what happens a lot to me. I have 1 file open and in
                    > another Vim instance I open the same file again only for viewing, so I
                    > would like to avoid the "Attention" prompt.
                    >
                    > On the other hand I can see, that it is certainly useful, if you start
                    > editing a file and immediately Vim warns you, that another Vim instance
                    > is already editing that file. Hm, may be a new option swaponchange or
                    > something?
                    >
                    > regards,
                    > Christian
                    >

                    IIUC, opening a file read-only (e.g. with :view rather than :edit) does
                    not create a corresponding swapfile.

                    If you open a file with :edit (or :split or :new etc.) (and that file
                    doesn't happen to have 'readonly' or 'nomodifiable' set for other
                    reasons), Vim has no way to know that you just want to look at the file,
                    not change it. When you know from the beginning that you won't make
                    changes in the file, always use :view (or :sview etc.) so Vim will set
                    'readonly' on that file (and, IIUC, not create a swapfile for it until
                    or unless you actually make a change).


                    Best regards,
                    Tony.
                    --
                    A disciple of another sect once came to Drescher as he was
                    eating his morning meal. "I would like to give you this personality
                    test", said the outsider, "because I want you to be happy."
                    Drescher took the paper that was offered him and put it into
                    the toaster -- "I wish the toaster to be happy too".

                    --
                    You received this message from the "vim_use" 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
                  • Gary Johnson
                    ... No. I don t want to undo my changes, I want to see my changes. Regards, Gary -- You received this message from the vim_use maillist. Do not top-post!
                    Message 9 of 25 , Aug 2 7:45 AM
                      On 2011-08-02, ZyX wrote:
                      > Reply to message «Re: swap files reverting my work erroneously»,
                      > sent 08:20:31 02 August 2011, Tuesday
                      > by Gary Johnson:
                      >
                      > > The trouble with
                      > > continually saving, though, is that you lose your reference for the
                      > > changes you've made to the file since you started editing. That's
                      > > not always important, but sometimes it's very handy. And having
                      > > swap files means I can do that without worry.
                      > Was not this solved by persistent undo introduced in vim-7.3?

                      No. I don't want to undo my changes, I want to see my changes.

                      Regards,
                      Gary

                      --
                      You received this message from the "vim_use" 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
                    • Reid Thompson
                      ... see histwin + gundo + persistent undo -- viewable permanent record of change tree -- You received this message from the vim_use maillist. Do not
                      Message 10 of 25 , Aug 2 7:49 AM
                        On Tue, 2011-08-02 at 07:45 -0700, Gary Johnson wrote:
                        On 2011-08-02, ZyX wrote:
                        > Reply to message «Re: swap files reverting my work erroneously», 
                        > sent 08:20:31 02 August 2011, Tuesday
                        > by Gary Johnson:
                        > 
                        > > The trouble with
                        > > continually saving, though, is that you lose your reference for the
                        > > changes you've made to the file since you started editing.  That's
                        > > not always important, but sometimes it's very handy.  And having
                        > > swap files means I can do that without worry.
                        > Was not this solved by persistent undo introduced in vim-7.3?
                        
                        No.  I don't want to undo my changes, I want to see my changes.
                        
                        Regards,
                        Gary
                        
                        

                        see histwin + gundo + persistent undo --> viewable permanent record of change tree

                        --
                        You received this message from the "vim_use" 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
                        ... I am sure there are plugins, that allow to do that. I have written changesPlugin http://www.vim.org/scripts/script.php?script_id=3052 that tries to
                        Message 11 of 25 , Aug 2 7:54 AM
                          On Tue, August 2, 2011 4:45 pm, Gary Johnson wrote:
                          > On 2011-08-02, ZyX wrote:
                          >> Reply to message «Re: swap files reverting my work erroneously»,
                          >> sent 08:20:31 02 August 2011, Tuesday
                          >> by Gary Johnson:
                          >>
                          >> > The trouble with
                          >> > continually saving, though, is that you lose your reference for the
                          >> > changes you've made to the file since you started editing. That's
                          >> > not always important, but sometimes it's very handy. And having
                          >> > swap files means I can do that without worry.
                          >> Was not this solved by persistent undo introduced in vim-7.3?
                          >
                          > No. I don't want to undo my changes, I want to see my changes.

                          I am sure there are plugins, that allow to do that. I have written
                          changesPlugin http://www.vim.org/scripts/script.php?script_id=3052
                          that tries to accomplish that (either against SCM or the saved version).


                          regards,
                          Christian

                          --
                          You received this message from the "vim_use" 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
                          ... Yeah, if just my fingers would remember ;) regards, Christian -- You received this message from the vim_use maillist. Do not top-post! Type your reply
                          Message 12 of 25 , Aug 2 7:54 AM
                            On Tue, August 2, 2011 3:27 pm, George Dinwiddie wrote:
                            > On 8/2/11 1:44 AM, Christian Brabandt wrote:
                            >> I have been thinking lately if it would be a good idea, if Vim would
                            >> only create a swap file, when it detects, that a change to the buffer
                            >> has been made. But not just when viewing a file.
                            >>
                            >> That is usually what happens a lot to me. I have 1 file open and in
                            >> another Vim instance I open the same file again only for viewing, so I
                            >> would like to avoid the "Attention" prompt.
                            >>
                            >> On the other hand I can see, that it is certainly useful, if you start
                            >> editing a file and immediately Vim warns you, that another Vim instance
                            >> is already editing that file. Hm, may be a new option swaponchange or
                            >> something?
                            >
                            > I'd just like to note that if you open the file in read-only mode (e.g.,
                            > with 'view <filename>'), then no swap file is created.

                            Yeah, if just my fingers would remember ;)

                            regards,
                            Christian

                            --
                            You received this message from the "vim_use" 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
                          • Gary Johnson
                            ... Yes, I _can_ do that, and I do that on occasion, but I don t _have_ to do that to have a reliable copy of the original state of the file and of my changes.
                            Message 13 of 25 , Aug 2 8:05 AM
                              On 2011-08-02, Tony Mechelynck wrote:
                              > On 2011-08-02, Gary Johnson wrote:
                              >> On 02/08/11 06:38, ZyX wrote:

                              > >>>I have swap files to prevent myself from editing one file in two vim
                              > >>>instances simultaneously. Though sometimes something goes wrong and vim
                              > >>>or the whole system crashes, but I never needed them to recover
                              > >>>anything. All you need to have the same behavior is to train yourself to
                              > >>>do «paused for thinking - hit {lhs of your mapping to :up} to save
                              > >>>file». For me it happens even more times then «stopped inserting - exit
                              > >>>insert mode».
                              > >>
                              > >>That's another good reason to use swap files. The trouble with
                              > >>continually saving, though, is that you lose your reference for the
                              > >>changes you've made to the file since you started editing. That's
                              > >>not always important, but sometimes it's very handy. And having
                              > >>swap files means I can do that without worry.
                              > >>
                              > >>Regards,
                              > >>Gary
                              >
                              > If you need a snapshot of a certain state of the disk file, take a copy.
                              > If you need successive snapshots, use numbered or dated backups, Vim
                              > supports them, after a fashion: see ":help backupext".

                              Yes, I _can_ do that, and I do that on occasion, but I don't
                              _have_ to do that to have a reliable copy of the original state of
                              the file and of my changes. Not doing that, I don't have to deal
                              with the clutter of backup copies that need to be deleted at some
                              point. For long-term backup and history retention, I use a VCS.

                              > I'm sure I'm not the only one on these lists who started editing at a
                              > time (and with an editor) where such luxuries as automatically recorded
                              > swapfiles simply didn't exist: for us old-timers, it has become a reflex
                              > to save the files whenever we stop editing (even if it's just to take a
                              > leak), and at least once every quarter-hour.

                              I started using Unix and vi in 1985 in an environment where people
                              would inadvertently unplug serial cables or coaxial LAN cables, and
                              where occasional lightning strikes and careless backhoe operators
                              would take out our power. I got in the habit of saving my work
                              regularly.

                              But now we have more reliable systems, and UPSs, and Vim with
                              automatic backups. My habits have changed. Now I save a file when
                              I'm done with a set of changes to it, not reflexively.

                              Regards,
                              Gary

                              --
                              You received this message from the "vim_use" 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
                            • George Dinwiddie
                              ... Yeah, I understand that. :) At least the Attention prompt gives an option for opening read-only. - George -- ... * George Dinwiddie *
                              Message 14 of 25 , Aug 2 8:15 AM
                                On 8/2/11 10:54 AM, Christian Brabandt wrote:
                                > On Tue, August 2, 2011 3:27 pm, George Dinwiddie wrote:
                                >> On 8/2/11 1:44 AM, Christian Brabandt wrote:
                                >>> I have been thinking lately if it would be a good idea, if Vim would
                                >>> only create a swap file, when it detects, that a change to the buffer
                                >>> has been made. But not just when viewing a file.
                                >>>
                                >>> That is usually what happens a lot to me. I have 1 file open and in
                                >>> another Vim instance I open the same file again only for viewing, so I
                                >>> would like to avoid the "Attention" prompt.
                                >>>
                                >>> On the other hand I can see, that it is certainly useful, if you start
                                >>> editing a file and immediately Vim warns you, that another Vim instance
                                >>> is already editing that file. Hm, may be a new option swaponchange or
                                >>> something?
                                >>
                                >> I'd just like to note that if you open the file in read-only mode (e.g.,
                                >> with 'view<filename>'), then no swap file is created.
                                >
                                > Yeah, if just my fingers would remember ;)

                                Yeah, I understand that. :) At least the "Attention" prompt gives an
                                option for opening read-only.

                                - George

                                --
                                ----------------------------------------------------------------------
                                * George Dinwiddie * http://blog.gdinwiddie.com
                                Software Development http://www.idiacomputing.com
                                Consultant and Coach http://www.agilemaryland.org
                                ----------------------------------------------------------------------

                                --
                                You received this message from the "vim_use" 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
                              • Gary Johnson
                                ... I have several plugins that do that for various SCMs and I have DiffOrig in my ~/.vimrc. I wasn t saying that I was in need of a way to see my changes,
                                Message 15 of 25 , Aug 2 8:24 AM
                                  On 2011-08-02, Christian Brabandt wrote:
                                  > On Tue, August 2, 2011 4:45 pm, Gary Johnson wrote:
                                  > > On 2011-08-02, ZyX wrote:
                                  > >> Reply to message «Re: swap files reverting my work erroneously»,
                                  > >> sent 08:20:31 02 August 2011, Tuesday
                                  > >> by Gary Johnson:
                                  > >>
                                  > >> > The trouble with
                                  > >> > continually saving, though, is that you lose your reference for the
                                  > >> > changes you've made to the file since you started editing. That's
                                  > >> > not always important, but sometimes it's very handy. And having
                                  > >> > swap files means I can do that without worry.
                                  > >> Was not this solved by persistent undo introduced in vim-7.3?
                                  > >
                                  > > No. I don't want to undo my changes, I want to see my changes.
                                  >
                                  > I am sure there are plugins, that allow to do that. I have written
                                  > changesPlugin http://www.vim.org/scripts/script.php?script_id=3052
                                  > that tries to accomplish that (either against SCM or the saved version).

                                  I have several plugins that do that for various SCMs and I have
                                  DiffOrig in my ~/.vimrc. I wasn't saying that I was in need of a
                                  way to see my changes, only that persistent undo is not a good
                                  solution for the problem under discussion.

                                  As I understand it, your plugin displays the same information as
                                  DiffOrig but in a less intrusive format. Its reference is still the
                                  file on disk.

                                  Regards,
                                  Gary

                                  --
                                  You received this message from the "vim_use" 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
                                  ... Ok ... Yes, but it can also take a file from a VCS as reference. regards, Christian -- You received this message from the vim_use maillist. Do not
                                  Message 16 of 25 , Aug 2 8:28 AM
                                    On Tue, August 2, 2011 5:24 pm, Gary Johnson wrote:
                                    > I have several plugins that do that for various SCMs and I have
                                    > DiffOrig in my ~/.vimrc. I wasn't saying that I was in need of a
                                    > way to see my changes, only that persistent undo is not a good
                                    > solution for the problem under discussion.

                                    Ok

                                    > As I understand it, your plugin displays the same information as
                                    > DiffOrig but in a less intrusive format. Its reference is still the
                                    > file on disk.

                                    Yes, but it can also take a file from a VCS as reference.

                                    regards,
                                    Christian

                                    --
                                    You received this message from the "vim_use" 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
                                  • ZyX
                                    Reply to message «Re: swap files reverting my work erroneously», sent 19:05:34 02 August 2011, Tuesday ... I started using vim and linux only a few years ago
                                    Message 17 of 25 , Aug 2 8:36 AM
                                      Reply to message «Re: swap files reverting my work erroneously»,
                                      sent 19:05:34 02 August 2011, Tuesday
                                      by Gary Johnson:

                                      > I started using Unix and vi in 1985 in an environment where people
                                      > would inadvertently unplug serial cables or coaxial LAN cables, and
                                      > where occasional lightning strikes and careless backhoe operators
                                      > would take out our power. I got in the habit of saving my work
                                      > regularly.
                                      >
                                      > But now we have more reliable systems, and UPSs, and Vim with
                                      > automatic backups. My habits have changed. Now I save a file when
                                      > I'm done with a set of changes to it, not reflexively.
                                      I started using vim and linux only a few years ago and did not do any serious
                                      work before that needed reflexive savings. The reason why I do them is that I
                                      decided that it is a good habit because
                                      1. if it is a habit you don't need to think and thus loose exactly no time to do
                                      a save (I already paused typing; I don't do it just because I typed too much);
                                      2. software contains bugs. I observed unreproducible X crashes several times and
                                      thus I need to know that I won't loose my work if something like this happens. I
                                      have an UPS but it won't help here. You can say that systems are more reliable
                                      this time, but I never did real work on less reliable systems, so for me these
                                      few crashes are already too much. The only thing that will make me think that
                                      some system is reliable is a mathematically correct proof of this. You can't
                                      write it for C code and for this very bold GNU C Compiler, can you?

                                      Original message:
                                      > On 2011-08-02, Tony Mechelynck wrote:
                                      > > On 2011-08-02, Gary Johnson wrote:
                                      > >> On 02/08/11 06:38, ZyX wrote:
                                      > > >>>I have swap files to prevent myself from editing one file in two vim
                                      > > >>>instances simultaneously. Though sometimes something goes wrong and
                                      > > >>>vim or the whole system crashes, but I never needed them to recover
                                      > > >>>anything. All you need to have the same behavior is to train yourself
                                      > > >>>to do «paused for thinking - hit {lhs of your mapping to :up} to save
                                      > > >>>file». For me it happens even more times then «stopped inserting -
                                      > > >>>exit insert mode».
                                      > > >>
                                      > > >>That's another good reason to use swap files. The trouble with
                                      > > >>continually saving, though, is that you lose your reference for the
                                      > > >>changes you've made to the file since you started editing. That's
                                      > > >>not always important, but sometimes it's very handy. And having
                                      > > >>swap files means I can do that without worry.
                                      > > >>
                                      > > >>Regards,
                                      > > >>Gary
                                      > >
                                      > > If you need a snapshot of a certain state of the disk file, take a copy.
                                      > > If you need successive snapshots, use numbered or dated backups, Vim
                                      > > supports them, after a fashion: see ":help backupext".
                                      >
                                      > Yes, I _can_ do that, and I do that on occasion, but I don't
                                      > _have_ to do that to have a reliable copy of the original state of
                                      > the file and of my changes. Not doing that, I don't have to deal
                                      > with the clutter of backup copies that need to be deleted at some
                                      > point. For long-term backup and history retention, I use a VCS.
                                      >
                                      > > I'm sure I'm not the only one on these lists who started editing at a
                                      > > time (and with an editor) where such luxuries as automatically recorded
                                      > > swapfiles simply didn't exist: for us old-timers, it has become a reflex
                                      > > to save the files whenever we stop editing (even if it's just to take a
                                      > > leak), and at least once every quarter-hour.
                                      >
                                      > I started using Unix and vi in 1985 in an environment where people
                                      > would inadvertently unplug serial cables or coaxial LAN cables, and
                                      > where occasional lightning strikes and careless backhoe operators
                                      > would take out our power. I got in the habit of saving my work
                                      > regularly.
                                      >
                                      > But now we have more reliable systems, and UPSs, and Vim with
                                      > automatic backups. My habits have changed. Now I save a file when
                                      > I'm done with a set of changes to it, not reflexively.
                                      >
                                      > Regards,
                                      > Gary
                                    • Gary Johnson
                                      ... I often encountered that problem in situations where I didn t have control over how Vim opened a file, so training my fingers wouldn t have helped. I
                                      Message 18 of 25 , Aug 2 8:39 AM
                                        On 2011-08-02, Christian Brabandt wrote:
                                        > On Tue, August 2, 2011 3:27 pm, George Dinwiddie wrote:
                                        > > On 8/2/11 1:44 AM, Christian Brabandt wrote:
                                        > >> I have been thinking lately if it would be a good idea, if Vim would
                                        > >> only create a swap file, when it detects, that a change to the buffer
                                        > >> has been made. But not just when viewing a file.
                                        > >>
                                        > >> That is usually what happens a lot to me. I have 1 file open and in
                                        > >> another Vim instance I open the same file again only for viewing, so I
                                        > >> would like to avoid the "Attention" prompt.
                                        > >>
                                        > >> On the other hand I can see, that it is certainly useful, if you start
                                        > >> editing a file and immediately Vim warns you, that another Vim instance
                                        > >> is already editing that file. Hm, may be a new option swaponchange or
                                        > >> something?
                                        > >
                                        > > I'd just like to note that if you open the file in read-only mode (e.g.,
                                        > > with 'view <filename>'), then no swap file is created.
                                        >
                                        > Yeah, if just my fingers would remember ;)

                                        I often encountered that problem in situations where I didn't have
                                        control over how Vim opened a file, so training my fingers wouldn't
                                        have helped. I often have several Vim instances open containing
                                        files I'm editing, so they have swap files. Then in one of those
                                        instances I'll use a tags command or a cscope command to find where
                                        a symbol is defined or used. If the symbol is in one of the files
                                        already open in a different Vim instance, I would get the swap file
                                        found error.

                                        I fixed that problem with the following SwapExists autocommand:

                                        if exists("##SwapExists")
                                        autocmd SwapExists * if v:swapcommand =~ '^:ta\%[g] \|^\d\+G$' | let v:swapchoice='o' | endif
                                        endif

                                        If the swap file exists and if the reason for opening the file is a
                                        tags or cscope command, the file is opened read-only.

                                        Regards,
                                        Gary

                                        --
                                        You received this message from the "vim_use" 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
                                        ... Really nice. I ll add that to my config. regards, Christian -- You received this message from the vim_use maillist. Do not top-post! Type your reply
                                        Message 19 of 25 , Aug 2 8:43 AM
                                          On Tue, August 2, 2011 5:39 pm, Gary Johnson wrote:
                                          > I often encountered that problem in situations where I didn't have
                                          > control over how Vim opened a file, so training my fingers wouldn't
                                          > have helped. I often have several Vim instances open containing
                                          > files I'm editing, so they have swap files. Then in one of those
                                          > instances I'll use a tags command or a cscope command to find where
                                          > a symbol is defined or used. If the symbol is in one of the files
                                          > already open in a different Vim instance, I would get the swap file
                                          > found error.
                                          >
                                          > I fixed that problem with the following SwapExists autocommand:
                                          >
                                          > if exists("##SwapExists")
                                          > autocmd SwapExists * if v:swapcommand =~ '^:ta\%[g] \|^\d\+G$' |
                                          > let v:swapchoice='o' | endif
                                          > endif
                                          >
                                          > If the swap file exists and if the reason for opening the file is a
                                          > tags or cscope command, the file is opened read-only.

                                          Really nice. I'll add that to my config.

                                          regards,
                                          Christian

                                          --
                                          You received this message from the "vim_use" 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
                                        • Joan Miquel Torres Rigo
                                          ... If this happen and the swapfile results to be obsolete, then you could easily loose the (updated) contets of the file (if you accidentally save it). Also,
                                          Message 20 of 25 , Aug 3 4:44 AM
                                            2011/8/2 David Ohlemacher <dohlemacher@...>:
                                            > So once you have a swap file from a crash its there forever.   That is until
                                            > you delete the swp manually.   And if you hit recover, your newer file
                                            > contents will be wiped out by an older swap file's contents?
                                            >
                                            > I assumed (word chosen carefully), that once you've recovered from a swap
                                            > file, the swap would be updated to mirror the current buffer.

                                            If this happen and the swapfile results to be obsolete, then you could
                                            easily loose the (updated) contets of the file (if you accidentally
                                            save it).

                                            Also, this obsolete swapfile may contains interesting changes not in
                                            the last version in disk and you could be interested in examine (and
                                            optionally merge) them.


                                            To handle this situations I use two mappings:

                                            command! Diff :w<space>!diff<space>-<space>%|less

                                            ...which lets me to examine the differences between the two files and
                                            decide if I want to use the swapfile version (:w), the disk version
                                            (:e %) or manually merge them starting from one or other.

                                            (I didn't know about DiffOrig mentioned by Gary below --but sure I
                                            will try it--)


                                            When resolved the conflict, I have this other mapping to drop the
                                            swapfile(s) easily and avoid future doubts.

                                            command! Recovered
                                            :!<space>rm<space>$(echo<space>%<space>|perl<space>-pe<space>'s/^(.*\/)?\.?(.*)$/\1.\2.swp\*/')

                                            ...this doesn't consider if there is more than one swapfiles and, off
                                            course, sure can be fully implemented without external commands. But
                                            it works for me ;-)


                                            Regards.

                                            --
                                            Joan Miquel Torres__________________________________
                                            Linux Registered User #164872
                                            http://www.mallorcaweb.net/joanmiquel
                                            BULMA: http://bulma.net http://breu.bulma.net/?l2301

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