-1

In my working directory,there are many files ending with "~"?
can i prevent win7 from creating that kind of file?

enter image description here

2 Answers 2

3

Form the screenshot you provided, I'm sure files with suffix ~ is produced by gvim.

Vim uses ~ file to make a backup of the file which you edited.

You may refer to Why does Vim save files with a ~ extension? for more details and instructions on how to avoid that.

2
  • I think Emacs creates them also. Though I suppose you're more likely to end up with Vim "inadvertently" on Windows than Emacs. It might be included in Git for windows. Jul 20, 2014 at 5:07
  • @BradyTrainor Yes, you are right. Emacs and many other programs also create a ~ file when modifing an existing file. For this particular question, I come to my conclusion from the screenshot provided. You may see the icon of vim before the filename.
    – pallxk
    Jul 21, 2014 at 10:00
9

Windows is not responsible for creating that file. And it is also not responsible for preventing creation of files with legal names.

Appending a ~ to the file name/extension is a common way for many programs to create a backup copy of the original file before saving, just in case you want to undo your changes. This is actually a more common pattern on FOSS/Linux programs, and tends to be carried with them when they are ported to Windows. Deal with whichever editor is creating the files in the first place.

2
  • Not Correct not only Foss/Linux Tools like gvim does it also word/Excel/Powerpoint make such files but thy have a different meaning they stand for the Actual open Document and are automatically removed when the file is closed.
    – konqui
    Jul 11, 2014 at 10:57
  • @konqui I meant the ~ to denote temporary files is a common pattern across FOSS programs. That does not mean other programs can't use it, and it also does not mean the pattern cannot mean anything else. MS Office doesn't use tildes anyway; its temporary file naming scheme is different. At no point did I say other programs may not create temporary files.
    – Bob
    Aug 15, 2014 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .