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

now swap file when loading file below a certain directory?

Expand Messages
  • meino.cramer@gmx.de
    Hi, can I instruct vim not to create a swap file, when the original file is below a certain directory??? Thank you very much for nay help in advance! Best
    Message 1 of 6 , Sep 15, 2011
    • 0 Attachment
      Hi,

      can I instruct vim not to create a swap file, when the original
      file is below a certain directory???

      Thank you very much for nay help in advance!

      Best regards and have a nice weekend!
      mcc


      --
      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
      ... :help swapfile says, This option can be reset when a swapfile is not wanted for a specific buffer. So, something like this in your ~/.vimrc should
      Message 2 of 6 , Sep 15, 2011
      • 0 Attachment
        On 2011-09-16, mcc wrote:
        > Hi,
        >
        > can I instruct vim not to create a swap file, when the original
        > file is below a certain directory???

        ":help 'swapfile'" says, "This option can be reset when a swapfile
        is not wanted for a specific buffer." So, something like this in
        your ~/.vimrc should work. (Untested)

        au BufNewFile,BufRead /path/to/directory/* setlocal noswapfile

        That will handle files _in_ a certain directory. I think changing
        the pattern to /path/to/directory/** will handle files in that
        directory and below.

        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
      • meino.cramer@gmx.de
        ... Hi Gary, that helps a lot! I knew of noswapfile, but I didnt know the directory-thingy! :) Thank you very much! Have a nice weekend! Best regards, mcc --
        Message 3 of 6 , Sep 16, 2011
        • 0 Attachment
          Gary Johnson <garyjohn@...> [11-09-16 17:26]:
          > On 2011-09-16, mcc wrote:
          > > Hi,
          > >
          > > can I instruct vim not to create a swap file, when the original
          > > file is below a certain directory???
          >
          > ":help 'swapfile'" says, "This option can be reset when a swapfile
          > is not wanted for a specific buffer." So, something like this in
          > your ~/.vimrc should work. (Untested)
          >
          > au BufNewFile,BufRead /path/to/directory/* setlocal noswapfile
          >
          > That will handle files _in_ a certain directory. I think changing
          > the pattern to /path/to/directory/** will handle files in that
          > directory and below.
          >
          > 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
          >

          Hi Gary,

          that helps a lot! I knew of noswapfile, but I didnt know the
          directory-thingy! :)

          Thank you very much!

          Have a nice weekend!
          Best regards,
          mcc

          --
          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
        • David Barnett
          ... I wanted the same thing, only in my case it was when using a very slow filesystem and it s very clear that the above autocmd only makes vim destroy the
          Message 4 of 6 , Aug 3 2:30 PM
          • 0 Attachment
            On Friday, September 16, 2011 9:42:51 AM UTC-7, meino....@... wrote:
            > Gary Johnson <gary…@...> [11-09-16 17:26]:
            > > On 2011-09-16, mcc wrote:
            > > > can I instruct vim not to create a swap file, when the original
            > > > file is below a certain directory???
            I wanted the same thing, only in my case it was when using a very slow filesystem and it's very clear that the above autocmd only makes vim destroy the swapfile again after creating it.

            I'd be very interested to see a way to prevent the swapfile from being created in the first place for certain paths. It seems like it's almost possible to disable swap by default and selectively enable it with some jiggering of autocmds, 'swapfile', and 'updatecount', but it's complicated by the fact that 'swapfile' is local-only and there doesn't seem to be any autocmd executed _after_ the buffer is initialized but _before_ the swapfile is created.

            David

            --
            --
            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.
          • Ben Fritz
            ... BufRead might work. But why do you want it before the swapfile is created? Setting swapfile will create it then and there if it s needed. -- -- You
            Message 5 of 6 , Aug 3 10:23 PM
            • 0 Attachment
              On Saturday, August 3, 2013 4:30:40 PM UTC-5, David Barnett wrote:
              > On Friday, September 16, 2011 9:42:51 AM UTC-7, meino....@... wrote:
              >
              > > Gary Johnson <gary…@...> [11-09-16 17:26]:
              >
              > > > On 2011-09-16, mcc wrote:
              >
              > > > > can I instruct vim not to create a swap file, when the original
              >
              > > > > file is below a certain directory???
              >
              > I wanted the same thing, only in my case it was when using a very slow filesystem and it's very clear that the above autocmd only makes vim destroy the swapfile again after creating it.
              >
              >
              >
              > I'd be very interested to see a way to prevent the swapfile from being created in the first place for certain paths. It seems like it's almost possible to disable swap by default and selectively enable it with some jiggering of autocmds, 'swapfile', and 'updatecount', but it's complicated by the fact that 'swapfile' is local-only and there doesn't seem to be any autocmd executed _after_ the buffer is initialized but _before_ the swapfile is created.
              >

              BufRead might work. But why do you want it before the swapfile is created? Setting 'swapfile' will create it then and there if it's needed.

              --
              --
              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.
            • Lech Lorens
              ... Why don t you just put the swap files on a faster filesystem? This can be done by setting dir appropriately. This has the advantage of not littering the
              Message 6 of 6 , Aug 4 3:40 AM
              • 0 Attachment
                On Saturday, August 3, 2013 11:30:40 PM UTC+2, David Barnett wrote:
                > On Friday, September 16, 2011 9:42:51 AM UTC-7, meino....@... wrote:
                >
                > > Gary Johnson <gary…@...> [11-09-16 17:26]:
                >
                > > > On 2011-09-16, mcc wrote:
                >
                > > > > can I instruct vim not to create a swap file, when the original
                >
                > > > > file is below a certain directory???
                >
                > I wanted the same thing, only in my case it was when using a very slow filesystem and it's very clear that the above autocmd only makes vim destroy the swapfile again after creating it.
                >
                >
                >
                > I'd be very interested to see a way to prevent the swapfile from being created in the first place for certain paths. It seems like it's almost possible to disable swap by default and selectively enable it with some jiggering of autocmds, 'swapfile', and 'updatecount', but it's complicated by the fact that 'swapfile' is local-only and there doesn't seem to be any autocmd executed _after_ the buffer is initialized but _before_ the swapfile is created.
                >
                >
                >
                > David

                Why don't you just put the swap files on a faster filesystem? This can be done by setting 'dir' appropriately. This has the advantage of not littering the directories with the edited files.

                HTH,
                Lech

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