vim temp files on windows

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

vim temp files on windows

Spam Spam

Hi,

Whenever I edit a file in gvim on Windows, a temporary
file of the same name but with a tilde (~) on the end
is created.

I presume these files should be deleted by vim when I
close the file, but they're not. Could anyone tell me
what settings I need to change to make sure it deletes
these temporary files. It's quite annoying having to
manually delete them all!

thanks,

- Kev


               
___________________________________________________________
How much free photo storage do you get? Store your holiday
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Mathias Michaelis
Hello Kev

> Whenever I edit a file in gvim on Windows, a temporary
> file of the same name but with a tilde (~) on the end
> is created.
>
This are backup files and are (meaningfully) not deleted after
closing the corresponding file.

In my $HOME/vimfiles directory I have created a folder named
"backup". Then, I putted in my .vimrc or _vimrc file the lines:

    "
    " keep a backup file
    "
    set backup
    set backupdir=$HOME/vimfiles/backup/

Now, all backup files are kept in this one backup directory. If you
don't like this at all, you can put the line

    set nobackup

at the place of the lines above.

Best regards

Mathias
Reply | Threaded
Open this post in threaded view
|

RE: vim temp files on windows

Amit GAHARWAR
In reply to this post by Spam Spam
Hi Kev,

Basically it’s a feature with vim that whenever you edit a file , the
original is saved as originalfilename~.
It’s a backup file that is created. It’s a good feature as you can always
revert to the original file.

Anyway if you don't want backup file,just add the following line in your
_vimrc file (I am using Windows and _vimrc file exists in C:\Program
Files\Vim)

   set nobackup.

Regards,

Amit Gaharwar,
Software Engineer,
WID, HPC,
Campus-II,
ST Microelectronics-NOIDA


-----Original Message-----
From: Spam Spam [mailto:[hidden email]]
Sent: Wednesday, July 20, 2005 2:18 PM
To: [hidden email]
Subject: vim temp files on windows



Hi,

Whenever I edit a file in gvim on Windows, a temporary
file of the same name but with a tilde (~) on the end
is created.

I presume these files should be deleted by vim when I
close the file, but they're not. Could anyone tell me
what settings I need to change to make sure it deletes
these temporary files. It's quite annoying having to
manually delete them all!

thanks,

- Kev


               
___________________________________________________________
How much free photo storage do you get? Store your holiday
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

A.J.Mechelynck
In reply to this post by Spam Spam
----- Original Message -----
From: "Spam Spam" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, July 20, 2005 10:47 AM
Subject: **SPAM** vim temp files on windows


>
> Hi,
>
> Whenever I edit a file in gvim on Windows, a temporary
> file of the same name but with a tilde (~) on the end
> is created.
>
> I presume these files should be deleted by vim when I
> close the file, but they're not. Could anyone tell me
> what settings I need to change to make sure it deletes
> these temporary files. It's quite annoying having to
> manually delete them all!
>
> thanks,
>
> - Kev

These are backup files: in olden DOS times, editors used to save the older
version of FILENAME.EXT under the name FILENAME.BAK. This (filename.ext~) is
better since it doesn't clobber the backup for one file with the backup for
a different file having the same name but a different extension.

In addition to what other people said (":set nobackup") you may want to
":set writebackup" which uses backup files, but only while your current edit
file is being written, and deletes them once the write operation is known to
have succeeded.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

jose isaias cabrera-2
In reply to this post by Mathias Michaelis

Thank you for this great idea.  Never even thought about it...


----- Original Message -----
From: "Mathias Michaelis" <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, July 20, 2005 5:01 AM
Subject: Re: vim temp files on windows


> Hello Kev
>
>> Whenever I edit a file in gvim on Windows, a temporary
>> file of the same name but with a tilde (~) on the end
>> is created.
>>
> This are backup files and are (meaningfully) not deleted after
> closing the corresponding file.
>
> In my $HOME/vimfiles directory I have created a folder named
> "backup". Then, I putted in my .vimrc or _vimrc file the lines:
>
>    "
>    " keep a backup file
>    "
>    set backup
>    set backupdir=$HOME/vimfiles/backup/
>
> Now, all backup files are kept in this one backup directory. If you
> don't like this at all, you can put the line
>
>    set nobackup
>
> at the place of the lines above.
>
> Best regards
>
> Mathias
>
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

c.lina
In reply to this post by Mathias Michaelis
On Wed, 20 Jul 2005 11:01:46 +0200
Mathias Michaelis <[hidden email]> wrote:

> Hello Kev
>
> > Whenever I edit a file in gvim on Windows, a temporary
> > file of the same name but with a tilde (~) on the end
> > is created.
> >
> This are backup files and are (meaningfully) not deleted after
> closing the corresponding file.
>
> In my $HOME/vimfiles directory I have created a folder named
> "backup". Then, I putted in my .vimrc or _vimrc file the lines:
>
>     "
>     " keep a backup file
>     "
>     set backup
>     set backupdir=$HOME/vimfiles/backup/
>
> Now, all backup files are kept in this one backup directory.[...]


Just one thought:
If you have the files math/chap1.tex and latin/chap1.tex,
then you have a backup file chap1.tex~ only of the last modified one.

Regards, Catherine.



> If you
> don't like this at all, you can put the line
>
>     set nobackup
>
> at the place of the lines above.
>
> Best regards
>
> Mathias
>


--
==================================================
Cras vives? Hodie iam vivere, Postume, serum est.
Reply | Threaded
Open this post in threaded view
|

RE: vim temp files on windows

Bouckaert, Hugo
In reply to this post by Spam Spam
Hi

What would be nice is that you create a directory called "backup"
directly under the one you are working in, with all the tilde (~) files
going in there.

That way the problem listed below won't occur and when you are finished
editing, you can simply delete the local backup directory in one go.

How would one set that up in the .vimrc file? Any ideas?

Thanks

Hugo  
 

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Thursday, 21 July 2005 3:12 PM
To: Mathias Michaelis
Cc: [hidden email]
Subject: Re: vim temp files on windows

On Wed, 20 Jul 2005 11:01:46 +0200
Mathias Michaelis <[hidden email]> wrote:

> Hello Kev
>
> > Whenever I edit a file in gvim on Windows, a temporary file of the
> > same name but with a tilde (~) on the end is created.
> >
> This are backup files and are (meaningfully) not deleted after closing

> the corresponding file.
>
> In my $HOME/vimfiles directory I have created a folder named "backup".

> Then, I putted in my .vimrc or _vimrc file the lines:
>
>     "
>     " keep a backup file
>     "
>     set backup
>     set backupdir=$HOME/vimfiles/backup/
>
> Now, all backup files are kept in this one backup directory.[...]


Just one thought:
If you have the files math/chap1.tex and latin/chap1.tex, then you have
a backup file chap1.tex~ only of the last modified one.

Regards, Catherine.



> If you
> don't like this at all, you can put the line
>
>     set nobackup
>
> at the place of the lines above.
>
> Best regards
>
> Mathias
>


--
==================================================
Cras vives? Hodie iam vivere, Postume, serum est.
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

c.lina
On Thu, 21 Jul 2005 16:19:38 +0800
"Bouckaert, Hugo" <[hidden email]> wrote:

> Hi
>
> What would be nice is that you create a directory called "backup"
> directly under the one you are working in, with all the tilde (~) files
> going in there.
>
> That way the problem listed below won't occur and when you are finished
> editing, you can simply delete the local backup directory in one go.
>
> How would one set that up in the .vimrc file? Any ideas?

In the same way as Mathias does it, but with another backupdir:

     " keep a backup file
     "
     set backup
     set backupdir=backup/

Of course, you have to create the directrory wherever/backup first.

Regards, Catherine.

>
> Thanks
>
> Hugo  
>  
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Thursday, 21 July 2005 3:12 PM
> To: Mathias Michaelis
> Cc: [hidden email]
> Subject: Re: vim temp files on windows
>
> On Wed, 20 Jul 2005 11:01:46 +0200
> Mathias Michaelis <[hidden email]> wrote:
>
> > Hello Kev
> >
> > > Whenever I edit a file in gvim on Windows, a temporary file of the
> > > same name but with a tilde (~) on the end is created.
> > >
> > This are backup files and are (meaningfully) not deleted after closing
>
> > the corresponding file.
> >
> > In my $HOME/vimfiles directory I have created a folder named "backup".
>
> > Then, I putted in my .vimrc or _vimrc file the lines:
> >
> >     "
> >     " keep a backup file
> >     "
> >     set backup
> >     set backupdir=$HOME/vimfiles/backup/
> >
> > Now, all backup files are kept in this one backup directory.[...]
>
>
> Just one thought:
> If you have the files math/chap1.tex and latin/chap1.tex, then you have
> a backup file chap1.tex~ only of the last modified one.
>
> Regards, Catherine.
>
>
>
> > If you
> > don't like this at all, you can put the line
> >
> >     set nobackup
> >
> > at the place of the lines above.
> >
> > Best regards
> >
> > Mathias
> >
>
>
> --
> ==================================================
> Cras vives? Hodie iam vivere, Postume, serum est.
>


--
==================================================
Cras vives? Hodie iam vivere, Postume, serum est.
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Mathias Michaelis
In reply to this post by c.lina
Hello Catherine

>> In my $HOME/vimfiles directory I have created a folder named
>> "backup". Then, I putted in my .vimrc or _vimrc file the lines:
>>
>>     "
>>     " keep a backup file
>>     "
>>     set backup
>>     set backupdir=$HOME/vimfiles/backup/
>>
>> Now, all backup files are kept in this one backup directory.[...]
>>
> Just one thought: If you have the files math/chap1.tex and
> latin/chap1.tex, then you have a backup file chap1.tex~ only of
> the last modified one.
>
Ok! I have changed the mentioned lines of my .vimrc file to

    set backup
    set backupdir=./backup,./../backup,$HOME/vimfiles/backup

If, in your examples, the directories math/backup and latin/backup
exist, the backup files are collected there. If not, they are placed
in a more general backup directory or in $HOME/vimfiles/backup.

You can also hide the ./backup directory if you want. (Under linux,
rename it to ./.backup)

OT: If you want to keep the original state of all files within a
project, do

    set patchmode=.orig

After you have edited math/chap1.txt and if math/chap1.txt.orig does
not exist yet, math/backup/chap1.txt~ is renamed to chap1.txt.orig.

Alas, there is no possibility to collect all .orig files in one
directory.

OT2: If you want to use options such as 'patchmode' or alternative
'backupdir's or not depends on the project you are working on. I
think the best way to manage such settings is with the help of vim
sessions (see :help *21.4*).

Best regards
Mathias
Reply | Threaded
Open this post in threaded view
|

RE: vim temp files on windows

Bouckaert, Hugo
In reply to this post by Spam Spam
Hi

Actually, I meant also creating a backup directory under the local
directory where the file is opened (only if the backup directory does
not exist already of course). In my case this would have to be done on a
Windows box.

Any ideas?

Thanks

Hugo  

-----Original Message-----
From: Mathias Michaelis [mailto:[hidden email]]
Sent: Thursday, 21 July 2005 4:27 PM
To: [hidden email]
Subject: Re: vim temp files on windows

Hello Catherine

>> In my $HOME/vimfiles directory I have created a folder named
>> "backup". Then, I putted in my .vimrc or _vimrc file the lines:
>>
>>     "
>>     " keep a backup file
>>     "
>>     set backup
>>     set backupdir=$HOME/vimfiles/backup/
>>
>> Now, all backup files are kept in this one backup directory.[...]
>>
> Just one thought: If you have the files math/chap1.tex and
> latin/chap1.tex, then you have a backup file chap1.tex~ only of the
> last modified one.
>
Ok! I have changed the mentioned lines of my .vimrc file to

    set backup
    set backupdir=./backup,./../backup,$HOME/vimfiles/backup

If, in your examples, the directories math/backup and latin/backup
exist, the backup files are collected there. If not, they are placed in
a more general backup directory or in $HOME/vimfiles/backup.

You can also hide the ./backup directory if you want. (Under linux,
rename it to ./.backup)

OT: If you want to keep the original state of all files within a
project, do

    set patchmode=.orig

After you have edited math/chap1.txt and if math/chap1.txt.orig does not
exist yet, math/backup/chap1.txt~ is renamed to chap1.txt.orig.

Alas, there is no possibility to collect all .orig files in one
directory.

OT2: If you want to use options such as 'patchmode' or alternative
'backupdir's or not depends on the project you are working on. I think
the best way to manage such settings is with the help of vim sessions
(see :help *21.4*).

Best regards
Mathias
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Mathias Michaelis
In reply to this post by Bouckaert, Hugo
Hello Hugo

> What would be nice is that you create a directory called "backup"
>  directly under the one you are working in, with all the tilde
> (~) files going in there.
>
As Cathrine said or see

http://groups.yahoo.com/group/vim/message/60454

Perhaps you could trick vim to create a vim directory whenever it
does not exist, e.g. under dos/windows by putting something like

:!if not exist backup\nul do mkdir backup

in your _vimrc file (I did not test this).

Best regards

Mathias
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Mathias Michaelis
In reply to this post by Bouckaert, Hugo
Hello Hugo

> Actually, I meant also creating a backup directory under the
> local directory where the file is opened (only if the backup
> directory does not exist already of course). In my case this
> would have to be done on a Windows box.
>
If you put the line

!start mkdir backup 2>nul

into your _vimrc file, this works almost properly. The only issue: A
nasty dialog appears whenever vim is started. I don't see why this
happens and how to avoid this. Perhaps you will find it out.

Thanks

Mathias
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

adah
In reply to this post by Spam Spam
"Start" has different behaviours on Windows 9x and Windows NT/2000/XP, so
should not be used here. Just "!mkdir backup" should achieve what you did.

For the current purpose, "call system('mkdir backup')" seems to achieve
what you wanted.

Best regards,

Yongwei





Mathias Michaelis <[hidden email]>
2005-07-21 17:16

 
        To:     Vim List <[hidden email]>
        CC:
        Subject:        Re: vim temp files on windows

Hello Hugo

> Actually, I meant also creating a backup directory under the
> local directory where the file is opened (only if the backup
> directory does not exist already of course). In my case this
> would have to be done on a Windows box.
>
If you put the line

!start mkdir backup 2>nul

into your _vimrc file, this works almost properly. The only issue: A
nasty dialog appears whenever vim is started. I don't see why this
happens and how to avoid this. Perhaps you will find it out.

Thanks

Mathias



Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Mathias Michaelis
Hallo Yongwei

> For the current purpose, "call system('mkdir backup')" seems to
> achieve what you wanted.
>
Thanks :-) It works!
Mathias
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

A.J.Mechelynck
----- Original Message -----
From: "Mathias Michaelis" <[hidden email]>
To: "Vim List" <[hidden email]>
Sent: Thursday, July 21, 2005 11:39 AM
Subject: Re: vim temp files on windows


> Hallo Yongwei
>
>> For the current purpose, "call system('mkdir backup')" seems to
>> achieve what you wanted.
>>
> Thanks :-) It works!
> Mathias

...however, since it must be invoked whenever you edit a new file (in a new
directory) but not when starting with an unnamed buffer or a buffer which
(like the one created by the ":options" command) is not to be written, I
believe that command should be put in an autocommand and not unconditionally
in the vimrc. I suggest:

    au BufReadPre,BufNewFile,BufFilePost * if (&buftype == "") &&
(expand("<afile>") != "") && (! isdirectory(expand("<afile>:p:h") .
'\backup')) | call system("mkdir " . expand("<afile>:p:h") . '\backup') |
endif

(untested, all on one line). This should also take care of the case when the
file being edited is not in the current directory. This is for Windows; for
Unix, replace the backslashes by a forward slashes. You may have to choose
other autocommand events if these do not happen soon enough.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Yegappan Lakshmanan
On 7/21/05, Tony Mechelynck <[hidden email]> wrote:
>
> in the vimrc. I suggest:
>
>     au BufReadPre,BufNewFile,BufFilePost * if (&buftype == "") &&
> (expand("<afile>") != "") && (! isdirectory(expand("<afile>:p:h") .
> '\backup')) | call system("mkdir " . expand("<afile>:p:h") . '\backup') |
> endif
>

In Vim7, you can use the built-in mkdir() function instead of calling the
external mkdir command using system().

- Yegappan
Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Spam Spam
In reply to this post by jose isaias cabrera-2

Thanks to everyone who replied to my question.

Much appreciated :o)

thanks,

- Kev

--- jose isaias cabrera <[hidden email]>
wrote:

>
> Thank you for this great idea.  Never even thought
> about it...
>
>
> ----- Original Message -----
> From: "Mathias Michaelis" <[hidden email]>
> To: <[hidden email]>
> Sent: Wednesday, July 20, 2005 5:01 AM
> Subject: Re: vim temp files on windows
>
>
> > Hello Kev
> >
> >> Whenever I edit a file in gvim on Windows, a
> temporary
> >> file of the same name but with a tilde (~) on the
> end
> >> is created.
> >>
> > This are backup files and are (meaningfully) not
> deleted after
> > closing the corresponding file.
> >
> > In my $HOME/vimfiles directory I have created a
> folder named
> > "backup". Then, I putted in my .vimrc or _vimrc
> file the lines:
> >
> >    "
> >    " keep a backup file
> >    "
> >    set backup
> >    set backupdir=$HOME/vimfiles/backup/
> >
> > Now, all backup files are kept in this one backup
> directory. If you
> > don't like this at all, you can put the line
> >
> >    set nobackup
> >
> > at the place of the lines above.
> >
> > Best regards
> >
> > Mathias
> >
>



       
       
               
___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
Reply | Threaded
Open this post in threaded view
|

RE: vim temp files on windows

Bouckaert, Hugo
In reply to this post by Spam Spam
Hi Tony

Yes, what you outline below would be absolutely ideal. However, it does
not create any backup directories in the directory where the file is
opened - tried a few variations but can't seem to get it to work. Any
ideas?

Thanks

Hugo
 

-----Original Message-----
From: Tony Mechelynck [mailto:[hidden email]]
Sent: Thursday, 21 July 2005 10:44 PM
To: Mathias Michaelis; Vim List
Subject: Re: vim temp files on windows

----- Original Message -----
From: "Mathias Michaelis" <[hidden email]>
To: "Vim List" <[hidden email]>
Sent: Thursday, July 21, 2005 11:39 AM
Subject: Re: vim temp files on windows


> Hallo Yongwei
>
>> For the current purpose, "call system('mkdir backup')" seems to
>> achieve what you wanted.
>>
> Thanks :-) It works!
> Mathias

...however, since it must be invoked whenever you edit a new file (in a
new
directory) but not when starting with an unnamed buffer or a buffer
which
(like the one created by the ":options" command) is not to be written, I

believe that command should be put in an autocommand and not
unconditionally
in the vimrc. I suggest:

    au BufReadPre,BufNewFile,BufFilePost * if (&buftype == "") &&
(expand("<afile>") != "") && (! isdirectory(expand("<afile>:p:h") .
'\backup')) | call system("mkdir " . expand("<afile>:p:h") . '\backup')
|
endif

(untested, all on one line). This should also take care of the case when
the
file being edited is not in the current directory. This is for Windows;
for
Unix, replace the backslashes by a forward slashes. You may have to
choose
other autocommand events if these do not happen soon enough.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

A.J.Mechelynck
----- Original Message -----
From: "Bouckaert, Hugo" <[hidden email]>
To: "Tony Mechelynck" <[hidden email]>; "Mathias Michaelis"
<[hidden email]>; "Vim List" <[hidden email]>
Sent: Friday, July 22, 2005 3:13 AM
Subject: RE: vim temp files on windows


> Hi Tony
>
> Yes, what you outline below would be absolutely ideal. However, it does
> not create any backup directories in the directory where the file is
> opened - tried a few variations but can't seem to get it to work. Any
> ideas?
>
> Thanks
>
> Hugo

Other than to keep trying other autocommand events -- no, I don't have any
ideas.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: vim temp files on windows

Meghdad Azriel
In reply to this post by Mathias Michaelis
Didn´t work for me...

It gave me an error saying that it could not make the backup file...


Mathias Michaelis wrote
Hello Kev

> Whenever I edit a file in gvim on Windows, a temporary
> file of the same name but with a tilde (~) on the end
> is created.
>
This are backup files and are (meaningfully) not deleted after
closing the corresponding file.

In my $HOME/vimfiles directory I have created a folder named
"backup". Then, I putted in my .vimrc or _vimrc file the lines:

    "
    " keep a backup file
    "
    set backup
    set backupdir=$HOME/vimfiles/backup/

Now, all backup files are kept in this one backup directory. If you
don't like this at all, you can put the line

    set nobackup

at the place of the lines above.

Best regards

Mathias