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

Re: Removing junk .swp files

Expand Messages
  • Edward Beckett
    mike s suggestion is I similar to what I use... and it works quite well... I also prepend the abs path to the file to avoid name collisions... ... -- -- You
    Message 1 of 13 , May 1, 2013
    • 0 Attachment

      mike's suggestion is I similar to what I use... and it works quite well... I also prepend the abs path to the file to avoid name collisions...

      On May 1, 2013 1:49 PM, "BPJ" <bpj@...> wrote:
      Is there any easy/automatized way to remove junk (as in not associated with any file currently open in (g)vim) .swp files
      in the current directory and its subdirectories?
      A plugin perhaps?

      /bpj

      --
      --
      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

      --- You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
      For more options, visit https://groups.google.com/groups/opt_out.


      --
      --
      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
       
      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       
    • tooth pik
      ... you re going to need an asterisk in front of that .swp -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply
      Message 2 of 13 , May 1, 2013
      • 0 Attachment
        On Wed, May 01, 2013 at 12:11:08PM -0700, Mike Hume wrote:
        > You could setup a tmp directory for where swp files are stores.

        > set directory=~/.vim/tmp/swap

        > If you have swp files littered about, run this command to
        > recursively find and delete them:

        > find . -type d -name .swp | xargs rm -rf

        you're going to need an asterisk in front of that '.swp'

        --
        --
        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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Edward Beckett
        And if you pass the -d argument to the find method it will never match swp files :-) ... -- -- You received this message from the vim_use maillist. Do not
        Message 3 of 13 , May 1, 2013
        • 0 Attachment

          And if you pass the -d argument to the find method it will never match swp files :-)

          On May 1, 2013 4:37 PM, "tooth pik" <toothpik6@...> wrote:
          On Wed, May 01, 2013 at 12:11:08PM -0700, Mike Hume wrote:
          > You could setup a tmp directory for where swp files are stores.

          > set directory=~/.vim/tmp/swap

          > If you have swp files littered about, run this command to
          > recursively find and delete them:

          > find . -type d -name .swp | xargs rm -rf

          you're going to need an asterisk in front of that '.swp'

          --
          --
          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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.


          --
          --
          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
           
          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
           
           
        • BPJ
          ... I know all that. But you may get junk swap files hanging around if you inadvertently compress a directory containing files which are currently open in Vim
          Message 4 of 13 , May 1, 2013
          • 0 Attachment
            2013-05-01 21:16, Ben Fritz skrev:
            > On Wednesday, May 1, 2013 2:12:58 PM UTC-5, Ben Fritz wrote:
            >>
            >> Such .swp files should never exist if you always exit Vim normally.
            >>
            >> Only when Vim crashes or gets terminated abnormally will you have such files hanging around.
            >>
            >
            > Also there may be swap files associated with a DIFFERENT Vim instance, especially if you or others edit files on a network location using Vim from multiple computers.
            >
            > Deleting them automatically might interfere with other Vim instances. I think you will always want a confirmation step at least before deleting swap files.
            >

            I know all that. But you may get junk swap files hanging around
            if you inadvertently compress a directory containing files which
            are currently open in Vim at compression time. Stupid, but there
            you have it!

            /bpj

            --
            --
            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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • George Dinwiddie
            Mike, BPJ ... That rm -rf can be a bit destructive when run on a directory. I suggest find . -name *.swp -exec rm {} ; This won t check to see if the
            Message 5 of 13 , May 2, 2013
            • 0 Attachment
              Mike, BPJ

              On 5/1/13 3:11 PM, Mike Hume wrote:
              > You could setup a tmp directory for where swp files are stores.
              >
              > set directory=~/.vim/tmp/swap
              >
              > If you have swp files littered about, run this command to recursively find and delete them:
              >
              > find . -type d -name .swp | xargs rm -rf

              That "rm -rf" can be a bit destructive when run on a directory.

              I suggest

              find . -name "*.swp" -exec rm {} ";"

              This won't check to see if the file is in use, so do it when vim isn't
              running.

              - George

              >
              > ~Mike
              >
              > On May 1, 2013, at 10:49 AM, BPJ <bpj@...> wrote:
              >
              >> Is there any easy/automatized way to remove junk (as in not associated with any file currently open in (g)vim) .swp files
              >> in the current directory and its subdirectories?
              >> A plugin perhaps?
              >>
              >> /bpj
              >>
              >> --
              >> --
              >> 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
              >>
              >> --- You received this message because you are subscribed to the Google Groups "vim_use" group.
              >> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              >> For more options, visit https://groups.google.com/groups/opt_out.
              >>
              >>
              >

              --
              ----------------------------------------------------------------------
              * 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

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Paul
              ... I don t recommend this, because like George Dinwiddie says, it doesn t check to see if any swap files are in use, but this is a more efficient command:
              Message 6 of 13 , May 8, 2013
              • 0 Attachment
                On Wednesday, 01 May, 2013 at 20:11:08 BST, Mike Hume wrote:
                >You could setup a tmp directory for where swp files are stores.
                >
                >set directory=~/.vim/tmp/swap
                >
                >If you have swp files littered about, run this command to recursively find and delete them:
                >
                >find . -type d -name .swp | xargs rm -rf

                I don't recommend this, because like George Dinwiddie says, it doesn't check to see if any swap files are in use, but this is a more efficient command:

                find ~ -type f -name \*.swp -delete

                --
                --
                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

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Gary Johnson
                ... Also, not all swap files end in .swp. If Vim needs to create a swap file and one ending in .swp already exists, Vim will use the extension .swo for the
                Message 7 of 13 , May 8, 2013
                • 0 Attachment
                  On 2013-05-08, Paul wrote:
                  > On Wednesday, 01 May, 2013 at 20:11:08 BST, Mike Hume wrote:
                  > >You could setup a tmp directory for where swp files are stores.
                  > >
                  > >set directory=~/.vim/tmp/swap
                  > >
                  > >If you have swp files littered about, run this command to
                  > >recursively find and delete them:
                  > >
                  > >find . -type d -name .swp | xargs rm -rf
                  >
                  > I don't recommend this, because like George Dinwiddie says, it
                  > doesn't check to see if any swap files are in use, but this is a
                  > more efficient command:
                  >
                  > find ~ -type f -name \*.swp -delete

                  Also, not all swap files end in .swp. If Vim needs to create a swap
                  file and one ending in .swp already exists, Vim will use the
                  extension .swo for the new one and .swn after that. I think it just
                  continues backwards through the alphabet. So using something like

                  \*.sw[nop]

                  or even

                  \*.sw?

                  would be more thorough.

                  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

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • Adrian Luff
                  ... Using xargs doesn t correctly handle files with spaces in their name by default in my environment. I m not sure of the portability of fixes for this so I
                  Message 8 of 13 , May 9, 2013
                  • 0 Attachment
                    Assuming you have the following in your .vimrc:
                    set directory=$HOME/.vim/swap

                    You can easily use find and metadata from the file system to remove files that have not been accessed in more than 30 days:

                    find ~/.vim/swap -type f -atime +30 -name \*.sw? -exec rm -f {} \;

                    Using xargs doesn't correctly handle files with spaces in their name by default in my environment. I'm not sure of the portability of fixes for this so I stuck with -exec.

                    -Adrian

                    On May 8, 2013, at 10:05 AM, Gary Johnson <garyjohn@...> wrote:

                    On 2013-05-08, Paul wrote:
                    On Wednesday, 01 May, 2013 at 20:11:08 BST, Mike Hume wrote:
                    You could setup a tmp directory for where swp files are stores.

                    set directory=~/.vim/tmp/swap

                    If you have swp files littered about, run this command to
                    recursively find and delete them:

                    find . -type d -name .swp | xargs rm -rf

                    I don't recommend this, because like George Dinwiddie says, it
                    doesn't check to see if any swap files are in use, but this is a
                    more efficient command:

                       find ~ -type f -name \*.swp -delete

                    Also, not all swap files end in .swp.  If Vim needs to create a swap
                    file and one ending in .swp already exists, Vim will use the
                    extension .swo for the new one and .swn after that.  I think it just
                    continues backwards through the alphabet.  So using something like

                       \*.sw[nop]

                    or even

                       \*.sw?

                    would be more thorough.

                    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

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.



                  Your message has been successfully submitted and would be delivered to recipients shortly.