LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2011, 10:00 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,543

Rep: Reputation: 51
Recovering a deleted file created by vim.


Hi: There are a lot of posts about recovering a deleted file. But my case is a special one, for I created it with Vim. When something goes wrong, I see that Vim has a .swp file that he uses for recovery.

I accidentally deleted (rm) a file with some 200 lines of text I have just written. Is there a possibility that I can recover it? Unfortunately, the backup file comprises barely a couple of lines. Is that .swp file always in the hard disk, from the moment of the text file creation? Because in this case, maybe Vim itself could help me to recover it. Thanks in advance.
 
Old 10-06-2011, 10:05 PM   #2
derstephen
Member
 
Registered: Sep 2011
Location: Northern Colorado
Distribution: Slackware64
Posts: 79

Rep: Reputation: Disabled
Whoops, didn't read the OP carefully enough. Unfortunately I think the only time vim uses the swap file is if something fails while it's still open, like if you're using ssh and lose your connection while editing a file, which happens to me all the time. But good luck nonetheless!

Last edited by derstephen; 10-06-2011 at 10:09 PM. Reason: Didn't read carefully enough
 
Old 10-06-2011, 10:31 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,543

Original Poster
Rep: Reputation: 51
Thanks. I now remember. I sometimes was editing some file in, say, virtual terminal /dev/tty3. Then I moved to /dev/tty1 and forgot about tty3. Finally I did 'poweroff', not realizing I had the file opened. Next time, when I opened it again, I found the infamous vim notification Abort, Quit, Recover, et cetera.
 
Old 10-07-2011, 08:01 AM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Vim deletes the .swp file when you properly close it.
 
Old 10-07-2011, 11:26 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,543

Original Poster
Rep: Reputation: 51
Thanks MTK358.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Recovering a file deleted with rm. stf92 Linux - Newbie 2 12-22-2010 07:19 AM
Recovering a deleted file on ext3... almost there! abegetchell Linux - Software 12 10-15-2009 10:10 AM
Recovering a deleted file brazilian_user Linux - General 2 08-09-2007 02:23 PM
Recovering the Deleted file how ? winxandlinx Linux - Software 1 09-21-2006 08:40 AM
recovering a deleted file? berrance Linux - Software 4 03-24-2006 07:56 AM


All times are GMT -5. The time now is 06:36 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration