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

Re: Disable swap file for large files?

Expand Messages
  • Ben Fritz
    ... Woah, woah, woah! Could one theoretically add to the autocmd that detects a large file, to (before setting undolevels) do something like: bufdo let
    Message 1 of 14 , Aug 22, 2013
      On Thursday, August 22, 2013 1:25:29 AM UTC-5, Christian Brabandt wrote:
      >
      > No. There are only two ways handling this. If you don't really change
      >
      > the buffer, you can disable the undo and later :rundo the
      >
      > existing undofiles.

      Woah, woah, woah!

      Could one theoretically add to the autocmd that detects a large file, to (before setting undolevels) do something like:

      bufdo let names[bufnr('%')] = tempname() | exe 'wundo' names[bufnr('%')]

      And then when closing the file/undoing the largefile settings,

      bufdo exe 'rundo' names[bufnr('%')]

      (with error handling and all that added of course).

      Probably would want to set 'nomodifiable' on all the buffers until the largefile settings were out of effect or something to prevent creating new changes not in the undo file.

      --
      --
      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.
    • Christian Brabandt
      ... Might work. Not sure, one wants to use several tempname() calls at all, since tempname() is only guaranteed to give distinct names for 26 calls and some
      Message 2 of 14 , Aug 22, 2013
        On Thu, August 22, 2013 16:37, Ben Fritz wrote:
        > On Thursday, August 22, 2013 1:25:29 AM UTC-5, Christian Brabandt wrote:
        >>
        >> No. There are only two ways handling this. If you don't really change
        >>
        >> the buffer, you can disable the undo and later :rundo the
        >>
        >> existing undofiles.
        >
        > Woah, woah, woah!
        >
        > Could one theoretically add to the autocmd that detects a large file, to
        > (before setting undolevels) do something like:
        >
        > bufdo let names[bufnr('%')] = tempname() | exe 'wundo' names[bufnr('%')]
        >
        > And then when closing the file/undoing the largefile settings,
        >
        > bufdo exe 'rundo' names[bufnr('%')]
        >
        > (with error handling and all that added of course).
        >
        > Probably would want to set 'nomodifiable' on all the buffers until the
        > largefile settings were out of effect or something to prevent creating new
        > changes not in the undo file.
        >

        Might work. Not sure, one wants to use several tempname() calls at all,
        since tempname() is only guaranteed to give distinct names for 26 calls
        and some plugins make use of tempname() themselves (so it could happen,
        that plugins overwrite the undofile).

        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

        ---
        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.
      • Charles Campbell
        ... I ve been trying it out, but I m going to have to put this mod down for now. I ve got BufLeave events firing when they shouldn t. Regards, Chip Campbell
        Message 3 of 14 , Aug 22, 2013
          Christian Brabandt wrote:
          > On Thu, August 22, 2013 16:37, Ben Fritz wrote:
          >> On Thursday, August 22, 2013 1:25:29 AM UTC-5, Christian Brabandt wrote:
          >>> No. There are only two ways handling this. If you don't really change
          >>>
          >>> the buffer, you can disable the undo and later :rundo the
          >>>
          >>> existing undofiles.
          >> Woah, woah, woah!
          >>
          >> Could one theoretically add to the autocmd that detects a large file, to
          >> (before setting undolevels) do something like:
          >>
          >> bufdo let names[bufnr('%')] = tempname() | exe 'wundo' names[bufnr('%')]
          >>
          >> And then when closing the file/undoing the largefile settings,
          >>
          >> bufdo exe 'rundo' names[bufnr('%')]
          >>
          >> (with error handling and all that added of course).
          >>
          >> Probably would want to set 'nomodifiable' on all the buffers until the
          >> largefile settings were out of effect or something to prevent creating new
          >> changes not in the undo file.
          >>
          > Might work. Not sure, one wants to use several tempname() calls at all,
          > since tempname() is only guaranteed to give distinct names for 26 calls
          > and some plugins make use of tempname() themselves (so it could happen,
          > that plugins overwrite the undofile).

          I've been trying it out, but I'm going to have to put this mod down for
          now. I've got BufLeave events firing when they shouldn't.

          Regards,
          Chip Campbell

          --
          --
          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.
        • Christian Brabandt
          Hi Charles! ... Well, we should convince Bram then to include the undolevels local patch then. regards, Christian -- Der Tourist am Seeufer: Er sieht einen
          Message 4 of 14 , Aug 22, 2013
            Hi Charles!

            On Do, 22 Aug 2013, Charles Campbell wrote:

            > Christian Brabandt wrote:
            > >On Thu, August 22, 2013 16:37, Ben Fritz wrote:
            > >>On Thursday, August 22, 2013 1:25:29 AM UTC-5, Christian Brabandt wrote:
            > >>>No. There are only two ways handling this. If you don't really change
            > >>>
            > >>>the buffer, you can disable the undo and later :rundo the
            > >>>
            > >>>existing undofiles.
            > >>Woah, woah, woah!
            > >>
            > >>Could one theoretically add to the autocmd that detects a large file, to
            > >>(before setting undolevels) do something like:
            > >>
            > >> bufdo let names[bufnr('%')] = tempname() | exe 'wundo' names[bufnr('%')]
            > >>
            > >>And then when closing the file/undoing the largefile settings,
            > >>
            > >> bufdo exe 'rundo' names[bufnr('%')]
            > >>
            > >>(with error handling and all that added of course).
            > >>
            > >>Probably would want to set 'nomodifiable' on all the buffers until the
            > >>largefile settings were out of effect or something to prevent creating new
            > >>changes not in the undo file.
            > >>
            > >Might work. Not sure, one wants to use several tempname() calls at all,
            > >since tempname() is only guaranteed to give distinct names for 26 calls
            > >and some plugins make use of tempname() themselves (so it could happen,
            > >that plugins overwrite the undofile).
            >
            > I've been trying it out, but I'm going to have to put this mod down
            > for now. I've got BufLeave events firing when they shouldn't.

            Well, we should convince Bram then to include the undolevels local patch
            then.

            regards,
            Christian
            --
            Der Tourist am Seeufer: Er sieht einen Tafel: "MÖVEN ZU VERKAUFEN".
            Was kostet eine Möve?
            DEM 2,60 das Stück.
            Dann nehme ich gleich fünf.
            Sehen sie sie, die Möven dort links oben, sie gehören nun ihnen.

            --
            --
            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.
          • Abhishek
            ... Hi, Here s something I use: let g:BufSizeThresholdSmall = 500000 No swap threshold (Set to 500 KB) let g:BufSizeThresholdBig =
            Message 5 of 14 , Aug 23, 2013
              On Wednesday, August 21, 2013 2:57:51 AM UTC+5:30, skeept wrote:
              > Is there a way of enabling swap files for files say less than 10Mb but disabling swap files for files or larger sizes?
              >
              > Thanks,
              >
              > Jorge

              Hi,

              Here's something I use:

              let g:BufSizeThresholdSmall = 500000 " No swap threshold (Set to 500 KB)
              let g:BufSizeThresholdBig = 1000000000 " Minimal mode threshold (Set to 1 GB)
              " For small files, switch all options on
              autocmd BufEnter * if getfsize(expand("<afile>")) < g:BufSizeThresholdSmall | set incsearch | setlocal statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P | endif
              " Don't use a swap file for big files
              autocmd BufReadPre * if getfsize(expand("<afile>")) >= g:BufSizeThresholdSmall | setlocal noswapfile | setlocal statusline=%<%f\ %h%m%r\ No\ Swap\ File%=%-14.(%l,%c%V%)\ %P | endif
              " Switch off other options for still bigger files
              autocmd BufEnter * if getfsize(expand("<afile>")) >= g:BufSizeThresholdBig | set noincsearch | setlocal noswapfile | setlocal statusline=%<%f\ %h%m%r\ No\ Swap\ File.\ No\ Incsearch%=%-14.(%l,%c%V%)\ %P | endif

              It allows two thresholds and disables more options for very large files. Moreover, the status line is updated to reflect the current state of options so that I know what to expect for the currently open file.

              PS: I don't remember if I copied it from somewhere or built it over time. In either case, corrections and suggestions for improvement are welcome. Will help me learn something new. :)

              Best Regards,
              Abhishek

              --
              --
              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
              It would be nice, if somebody took some of the suggestions in this thread and incorporated them into: http://vim.wikia.com/wiki/Faster_loading_of_large_files
              Message 6 of 14 , Aug 23, 2013
                It would be nice, if somebody took some of the suggestions in this thread and incorporated them into:

                http://vim.wikia.com/wiki/Faster_loading_of_large_files

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