now swap file when loading file below a certain directory?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

now swap file when loading file below a certain directory?

meino.cramer
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
Reply | Threaded
Open this post in threaded view
|

Re: now swap file when loading file below a certain directory?

Gary Johnson-4
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
Reply | Threaded
Open this post in threaded view
|

Re: now swap file when loading file below a certain directory?

meino.cramer
Gary Johnson <[hidden email]> [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
Reply | Threaded
Open this post in threaded view
|

Re: now swap file when loading file below a certain directory?

David Barnett
On Friday, September 16, 2011 9:42:51 AM UTC-7, [hidden email] wrote:
> Gary Johnson <gary…@spocom.com> [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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: now swap file when loading file below a certain directory?

Benjamin Fritz
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, [hidden email] wrote:
>
> > Gary Johnson <gary…@spocom.com> [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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: now swap file when loading file below a certain directory?

Lech Lorens
In reply to this post by David Barnett
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, [hidden email] wrote:
>
> > Gary Johnson <gary…@spocom.com> [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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.