LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-14-2012, 10:39 AM   #1
dspjm
Member
 
Registered: Dec 2010
Distribution: Scientific Linux Slackware
Posts: 91

Rep: Reputation: 2
Why does vim keep a backup file?


A file suffixing ~ is created right before you write but is deleted write after you successfully written, if you don't have backup set but writebackup set.
So what's the use of this backup file
 
Old 11-14-2012, 02:40 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
It is a very old program. A lot of odd things were done because of reasons we don't have today. Simple thing might have been very limited ram. You'd have to find the guys that made it or find any old documentation but I'd suspect a person who were to re-write it today would do it much differently.
 
1 members found this post helpful.
Old 11-14-2012, 08:05 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
To build on what Jefro said, in the early days of personal computers 30 or more years ago (I never used mainframes) it was not uncommon for computers just to lock up in the middle of something and have to be restarted.

Automatic backups were extremely prudent.
 
2 members found this post helpful.
Old 11-14-2012, 08:05 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
To build on what Jefro said, in the early days of personal computers 30 or more years ago (I never used mainframes) it was not uncommon for computers just to lock up in the middle of something and have to be restarted.

Automatic backups were extremely prudent.
 
2 members found this post helpful.
Old 11-14-2012, 08:10 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Also very handy over a dodgy cxn.
 
2 members found this post helpful.
Old 11-14-2012, 09:00 PM   #6
padeen
Member
 
Registered: Sep 2009
Location: Perth, W.A.
Distribution: Slackware, Debian, Gentoo, FreeBSD, OpenBSD
Posts: 208

Rep: Reputation: 41
You will appreciate it if you are editing a remote file over ssh. If the link goes down (ignoring tmux or screen for the sake of this example) or the remote host is rebooted by the hosting company, your vim edits are safe and recoverable.

If a bunch of ~ files annoys you, put them all in one place by specifying "set backupdir=xxxxx" and run a cron job periodically to delete old files in that directory.
 
4 members found this post helpful.
Old 11-15-2012, 07:00 AM   #7
pejobe
LQ Newbie
 
Registered: Nov 2009
Posts: 21

Rep: Reputation: 3
If you don't want any ~ files written. Write "set nobackup" in the end of your .vimrc file.
 
2 members found this post helpful.
Old 11-15-2012, 03:23 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Tried to give everyone a point but maybe gave out two on a few. All good additions to question.
 
1 members found this post helpful.
Old 11-16-2012, 10:35 AM   #9
dspjm
Member
 
Registered: Dec 2010
Distribution: Scientific Linux Slackware
Posts: 91

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by padeen View Post
You will appreciate it if you are editing a remote file over ssh. If the link goes down (ignoring tmux or screen for the sake of this example) or the remote host is rebooted by the hosting company, your vim edits are safe and recoverable.

If a bunch of ~ files annoys you, put them all in one place by specifying "set backupdir=xxxxx" and run a cron job periodically to delete old files in that directory.
That sounds about right, I just saw these files a few times, while I don't think it comes from vim, because I found no reason to generate a ~file in such manner. Maybe it comes from gedit.
 
1 members found this post helpful.
Old 11-16-2012, 11:52 AM   #10
Basher52
Member
 
Registered: Mar 2004
Location: .SE
Distribution: Arch
Posts: 401

Rep: Reputation: 22
..don't even microcrap's "office" do the same..
as far I've seen they do
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vim: jumping from file c1 to file c2 without saving c1 first. stf92 Linux - Newbie 9 08-02-2011 08:23 PM
vim file.tex !latex file.tex & pdfdvi file.dvi & xpdf -remote sname -reload Mol_Bolom Linux - General 0 07-09-2009 07:46 PM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 04:26 PM
vim always says swap file already exists for a particular file leftty Linux - Software 1 09-13-2008 01:53 PM
Error when attempting backup with File Backup lglrgl Linux - Software 0 08-03-2006 10:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration