is there an autosave function/plugin for notepad++? - plugins

After an unplanned system restart, all of my Notepad++ temp (and unsaved) tabs are gone.
How can I avoid this in future?
I don't want to have to save explicitly every single temp file with a file name.
Is there a plugin for NP++, which saves my session every time I'm editing an active tab or every X minutes?
Or is there an equivalent (and comfortable) editor to NP++, which autostores it's session automatically?

You can find a Notepad++ plugin called AutoSave for autosaving your files here: https://github.com/francostellari/NppPlugins/tree/main/AutoSave
(Used to link to https://sites.google.com/site/fstellari/nppplugins but that's no longer online, cached version is still available here)
It autosaves every minute, but it's configurable, and allows you to choose to save only the current document or all open documents.

From Notepad++ 6.6 or later there are in core and don't need any plugin.
Via menu => Settings => Preferences => Backup => Enable session snapshot and periodic backup

To date, there are two AutoSave plugins available.
To download, click on the Plugins menu and select Plugin Manager (or Plugins Admin). It will pop-up a window with a list of plugins.
Autosave by Franco-stellari —
This autosaves files. Option available to configure timing after autosave, or autosave when npp loses focus.
Autosave2 by www.scout-soft.com - This autosaves files by creating copy of the file. This is useful in case you retain previous saves, such as for incremental development.
Select either of the two AutoSave plugin available and click on Install. If the plugins are not listed, use the links above, and save the .dll to npp's plugins folder according to instructions on the sites.
Update:
in the newest version of Notepad++:
save the plugin's .DLL in Notepad++'s plugins\[plugin name] folder,
go Settings→Import→Import Plugin(s)... and select the .DLL you just saved,
Restart N++. The plugin should appear in the "Plugins" menu.

UPDATE 2022
For those who look for answear on similar question, I`ll try to give detailed description.
I`m personnaly use integrated backup/autosave for Notepad++ which, I think cover any needs for this functionality and better option can be only files versioning tools like git/hg etc.
So...
Go to:
Settings / Preferences / Backup
This will open settings which containe two section:
Session snapshot and periodic backup
Backup on save
First option in first section is Remember current session for next launch:
After enable this, on restart NP++ will be open all session related instances, like opened files, project in projects panel etc, from previous session. But this may did not help if NP++ for some reason was unexpectedly closed(the process freezes, the power supply of the computer is interrupted, etc.) and as result you lost unsaved state of your files.
To partially protect against such an unpleasant accident, you can use the following option: Enable session snapshot and periodic backup:
After enable this, NP++ will after the interval specified in the option Backup in every N seconds, check all open and UNsaved in NP++ files, and save a copy of them with a timestamp in the file name extension(if in Windows explorer display extensions dissabled you can't see timestamp and see only filename wo extension), to the folder specified in the Backup path option.
d:\Temp\ff_stickers.js
d:\SYNCFOLDER\Settings\NP++\backup\ff_stickers.js#2022-04-19_141352
After you save original file, NP++ immediately delete this backup copy.
Also, enabling this option allows you to exit NP++ without saving opened and unsaved files. When you close the NP++, it does not prompt you to save opened and unsaved files, and the next time you open it, it displays them in the same way as before close - marked as unsaved.
Regarding the option Backup path - you cannot change this path,
because it depends on where the NP++ configuration files are stored.
By default, this is the folder backup in same folder where NP++
itself is located. In my case (on my screen), this path is located in
the same place as the configuration files path, specified in the Cloud
option:
Which was added to be able to synchronize NP++ settings.
The next options, already in the second section:
None
Simple backup
Verbose backup
With option Simple backup:
while you save original file in NP++, it will add *.bak file with previous saved state, next to the original:
d:\Temp\ff_stickers.js
d:\Temp\ff_stickers.js.bak
This *.bak remains the only one and is replaced on every save of original file.
With option Verbose backup:
while you save original file in NP++, it will add subfolder nppBackup next to the original file, and save there *.bak file with previous saved state.
d:\Temp\ff_stickers.js
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_141952.bak
These files are not replaced when you save the original, and there are remain as many of them as you save the origanal file.
d:\Temp\ff_stickers.js
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_141952.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142717.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142718.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142719.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142720.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142721.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142722.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142723.bak
d:\Temp\nppBackup\ff_stickers.js.2022-04-19_142732.bak
And last option Directory, allows you to save *.bak files to a directory of your choice(here you can specify an arbitrary path).
d:\Temp\ff_stickers.js
d:\taravasya\BackUps\NPpp\ff_stickers.js.2022-04-19_143305.bak
Hope it help to use this great app and will save someone a lot of time and nerves))

Update November 2020
Autosave as it should be works on Notepad 32 bit V7.9.1
Before Nov. 2020
The autosave without a backup copy (just save after a time interval or by loosing the focus on the file) seems DEAD as of 2020.

AutoSave In Notepad++
You can enable the AutoSave function in Notepad++ using the below Steps:
Open Notepad++
Open Plugins on Top/ Plugins Admin.
Now Search for AutoSave from the options and Select it
Click on Install, Notepad++ will get restarted
i.e, you can find that plugin under the plugin area on the top.
NB: Just go to the Autosave plugin and enable the time what you want in "Options".
That's it ! COMPLETED

Related

Restore or access workspaces from MySQL Workbench

Using MySQL Workbench 6.3.8 build 1228 CE (64-bit), on Windows 10 Pro, version 1803, build 17134.112.
I want to restore my old workspaces in MySQL Workbench. If that is not possible, I will be happy with just being able to access them as text files.
I guess my laptop had an unusual power-off or reset last night. Normally I put it in Sleep mode, but when I opened it this morning it had reset itself: all applications had quit.
I re-opened Workbench, and got this error message:
saying that my workspaces could not be opened.
I can't get the full text of the error message, so I don't know exactly where Workbench is looking, but using Windows Explorer I could navigate to:
C:\Users\JamesBarton\AppData\Roaming\MySQL\Workbench\sql_workspaces
which looks right to me, and contains .workspace and .autosave directories.
I've backed up the Workbench\ directory, and then tried just removing the .autosave directories, to force the use of the .workspace directories, but when I did that, Workbench still just opened one empty tab. The first .workspace directory contains 95 files, including 45 .scratch files totalling 107kb.
Is it possible to check exactly where MySQL Workbench is looking for workspaces?
Can I force it to open a workspace directly, or at least show me why it can't open a workspace? If that is not possible, can I somehow extract the SQL from the .scratch files? Thanks.
Should be easy to recover the sql from the scratch files which are just plain text files. The sql code is not encrypted. Also you can look in the Workbench log file (see Help menu) to see if there's an error message or similar for a specific file. Could be there's some file corruption. Running the file system checker on that disk also might help.
PS: in Windows you can use the clipboard in system dialogs like this one. Just press Ctrl+C while the dialog has the focus to copy the entire text, including the button captions, to the clipboard. That will hopefully give you the full error message.
Even though my desktop has crashed several times in the past 3 years (either power-related or system) this last time was the first time MySQL Workbench had issues with a workspace (apparently the 2 I had open at the time?). When I investigated why I discovered that all the .info and .scratch files in those workspaces were written with only NUL characters so no easy recovery of my tabs is possible. Grrr.
I will have to recover everything from scratch (haha) by going through the sql_history and possibly log folders and copy/paste as necessary back into the GUI.

Restore a deleted file in the Visual Studio Code Recycle Bin

Using Visual Studio Code Version 1.8.1 how do I restore a deleted file in the recycle bin?
It uses the normal trash bin of your system. So you can grab it our of there.
In Windows you find it in the explorer, in Linux it is as well in Konquerer / Nemo / ...
First go to Recycle Bin of your local machine.
Your VS code deleted files is there in Recycle Bin.
So, Right click on deleted files and select-> Restore option then your deleted files
will be automatically restored in your VS code.
If you just deleted the file, know that VSCode 1.52 (Dec. 2020) will support:
Undo file operations in Explorer
Explorer now supports Undo and Redo for all file operations: delete, rename, copy, move, new file and new folder.
Make sure the focus is in the Explorer and trigger the Undo or Redo commands and your last file operation will be undone or redone respectively.
Keep in mind that we have separate undo stacks for the editor and the explorer and we choose which one to undo based on focus.
Running on Ubuntu 18.04, with VS code 1.51.0
My deleted files from VS Code are located at:
~/.local/share/Trash/files
Every deleted file have a corresponding .trashinfo file which contains details about where the file is deleted from and deletion date and these are located at:
~/.local/share/Trash/info
More info here.
To search for your deleted files:
find ~/.local/share/Trash/files -name your_file_name
In case you deleted files form a mounted ntfs filesystem, they will be located at:
/path_to_mounted_fs/.Trash-$UID
You can get $UID by doing echo $UID in your terminal.
Hope my case helped!
Click in empty space of VS Code's explorer (it's where you see files listed vertically) and press undo Ctrl + z
It'll recover your permanently deleted files too.
VS Code is a lifesaver. ✌
I know the OP says Recycle Bin. What I do though is recreate the file, especially if it's a single file. And when in the file, I just press CMD+Z (I'm on a Mac) and I get my file back.
Recreate the file in the same directory from where it was
deleted.
CMD+Z inside of the newly created file.
I accidentally discarded changes in the Source Control in VS Code, I just needed to reopen this file and press Ctrl-Z few times, glad that VS Code saves your changes like that.
If you can't find your files in the Windows Recycle Bin as it happended to me
(debugger went rogue and deleted the project folder)
look in the %APPDATA%\Code\User\History\ subfolders sorted by date modified.
There I could retrieve my seemingly lost files.
who still facing the problem on linux
and didnt find it on trash
try this solution
https://github.com/Microsoft/vscode/issues/32078#issuecomment-434393058
find / -name "delete_file_name"
If you have permanently deleted files, on macOS, you can see the history (the last month I guess) in $HOME/Library/Application Support/Code/User/History/. You will have to find your file(s) by looking at each entries.json file in every subfolder and rename the last version of your file.
There is probably a similar way on windows and linux but I don't know the precise paths.
I tried most of the options above but none worked.
What worked for me was clicking and highlighting the folder where the file was deleted from in vscode. Then while it is selected, hit CTRL + Z.
This works on windows.
Hitting CTRL+Z without highlighting that folder didn't work.
Just look up the files you deleted, inside Recycle Bin. Right click on it and do restore as you do normally with other deleted files. It is similar as you do normally because VS code also uses normal trash of your system.
While pushing a repository to Github through Vs Studio code I deleted whole folder and they were not available in Recycle bin also. Here is how I recovered those files.
For Windows.
The method is to restore the previous version of the Drive in which the deleted file existed
I had deleted files from G: drive, the below images are self explanatory
Open properties menu of the drive
In properties go to previous versions tab,
where you can find the previously stored versions of that drive along with date at time of backup
use open or click on restore to get the previous version of that drive.
Note: Manipulations in the drive after restore point won't be available
I am not sure how I deleted a file in VS Code, and couldn't find it in recycle bin. Found the file using the History feature of File Explorer.
A month recovery can be done in visual studio code
1 Right click on file and
2 click Open Timeline and
3 select file from timeline
4 the last time file saved by you
5 and your last change of the file is recovered
NOTE : Not only last but all the previously saved check points can be recoverd from vs code
For Mac, try to search some parts of the code in the deleted file in the following path:
~/Library/Application Support/Code
I found a deleted file in this folder
~/Library/Application Support/Code/Backups
Yes, I know this question is about VS Code but I think I can help someone.
I permanently deleted a file, and I tried all the tips wrote here with no success. So I had to recover the file from OS Linux following this
grep -a -C 500 -F 'Unique string in text file' /dev/sda
It was asked above if there is a way to disable the ability to delete a file you created with an undo (#rochasdv).
There is a new setting to disable undo for file operations:
Explorer: Enable Undo default is warn, confirmation dialog
You can also set it to disable so that your files/folders will not participate in undo operations.
You can alo set it to allow - the pre-new setting situation.
Currently, this new setting is in the Insiders Build v1.64 so it may be in Stable early February, 2022.
I am working on Windows with a Ubuntu WSL. I permanently deleted a file by mistake and was not able to restore it from the recycle bin nor by doing anything else.
I however, was able to get my files content by going to "Timeline" and see all my previous modification (it will open a comparison window).
Hope it will help somebody.
I had the case that I, accidentally, deleted a committed file (git) with a ton of additional uncommitted changes, and I could not get it back. (two days of work! yeah, I know, commit early commit often, I know ...)
I had no linux trash can setup on my docker instance and was developing via remote ssh.
I tried to recreate the file and then do a ctrl+Z to recapture the changes as some suggested here. This did not work for me.
So after a struggle over an hour I finally gave up and thought the changes to the file were lost.
However,
I discarded the changes in git, that the file was deleted.
And THEN I retried ctrl+Z and boom all the changes previously came back
magically!
I was a happy camper!
If your local directory has git initialized and you have not committed the changes that include the delete, you can use git checkout -f to throw away local changes.
If you completely delete any of the components in angular using visual code, you can restore it
Go to Recycle Bin and restore the deleted component that will be restored in the project.

File erased in Eclipse

I have a weird one.
I was working on a project in Eclipse (with CDT) when my computer went blue-screen. I remember saving all the files quite recently before that. The computer rebooted with no problems, but when I opened Eclipse again, the file that I was editing at the time was empty (not deleted, so I can't Restore from Local History). All the other files were intact. What happened, is this a problem with Eclipse or my computer, and how can I retrieve the file?
EDIT: I viewed the file using vim on Cygwin and actually it wasn't empty, it was full of unprintable ^# characters.
Right click on the file and choose 'Replace with > Local History...'. This will show you the last few versions of the file that Eclipse has saved.
Checking local history in eclipse didn't actually show anything, but I did solve it another way. What I did is I went to <workspace>/.metadata/.plugins/org.eclipse.core.resources/.history as suggested here, and sorted the entries by last modified. I scrolled down to the latest entry before the crash, then opened the files inside it one by one until I found the file that was erased.

Eclipse local file history

In eclipse, you can right click in a file and then select Team / Show local history. This shows your local saves and is pretty useful.
Now, I made some changes to a file. I am 100% certain I made them. But they have disappeared. Overwritten by someone else I guess. But when I check my local history I can't see my file changes.
My question is:
Does Eclipse always update the local file history for every save? How reliable is it?
Note: I appreciate people are thinking how can someone else overwrite your files. I am working in a force.com project. When you make changes to a file they are push to a central server. There is source control per se. It is like everyone working with a shared folder.
It depends. Each Eclipse plugin dealing with workspace artifacts can optionally set a flag for local history in its API calls to the workspace resource management when deleting or changing files. If the flag is set, changed files surely get copied into local history. But every plugin can set this flag different.
So even if you might have an editor plugin which always uses local history when saving the edited file, another plugin might delete/modify the file without using local history and therefore interfere.
Summary: Local history is not a reliable way to go back to previously saved versions of a file.
If anyone else runs into this issue, check to make sure you didn't accidentally edit a file in a build or target directory. For instance if you are working on a jsp page and make edits, swear you changed it but they are no longer there in the editor or the local history when you open the file, check to make sure you weren't editing the built version by accident.
This sometimes happens if you are quick to use ctrl-shift-R shortcut to open resources. To avoid this, you can set your build or target folder to derived by right clicking on the folder and checking the derived checkbox. This will prevent the resource from showing in the Open Resource view which could save you headaches later.
To get the code back, I opened the target version and used undo to get to the edited version.

Eclipse's local history...where are files saved?

Can someone explain how Eclipse's local history works?
I accidentally overwrote a file in a project but need to revert to an earlier version.
Is there a chance that Eclipse has the older file cached somewhere?
To complete CurtainDog's answer: from eclipse FAQ
Every time you modify a file in Eclipse, a copy of the old contents is kept in the local history. At any time, you can compare or replace a file with any older version from the history.
Although this is no replacement for a real code repository, it can help you out when you change or delete a file by accident.
Local history also has an advantage that it wasn’t really designed for: The history can also help you out when your workspace has a catastrophic problem or if you get disk errors that corrupt your workspace files.
As a last resort, you can manually browse the local history folder to find copies of the files you lost, which is a bit like using Google’s cache to browse Web pages that no longer exist.
Each file revision is stored in a separate file with a random file name inside the history folder. The path of the history folder inside your workspace is
.metadata/.plugins/org.eclipse.core.resources/.history/
You can use your operating system’s search tool to locate the files you are looking for.
Note, if your need to import your local history into a new workspace, you will need both:
.metadata/.plugins/org.eclipse.core.resources/.history
.metadata/.plugins/org.eclipse.core.resources/.project
to have a functional local history in that new workspace.
Try right-clicking on the file in eclipse, and choose Replace With->Local History.
If there's history available, it'll show up as a list of edit times.
But more importantly, as pointed out in other answers, be sure to put your files in version control! SVN is pretty easy to set up (you don't need a server; it can just use the file system); use it even if you aren't sharing with others.
A tip: whenever you hear yourself say "yes!", check in all of your code. 10 minutes later, you'll be saying "how did I mess that up?"
If you have lost a full package structure due to accidental deletion or svn/cvs override, select the project> right click> Restore from local history => select the files.
VonC's answer has all the information you need for finding the location of your code backups. I would simply add that if you are on a Mac or Linux, you can do something like this:
$ cd [WORKSPACE]/.metadata/.plugins/org.eclipse.core.resources/.history/
$ grep -rl "class Foo" . | xargs ls -lt
This will find all the versions of a file that contains a particular string (ie. "class Foo"), and sort them by date/time to easily find the most recent version.
You can use the link http://wiki.eclipse.org/FAQ_Where_is_the_workspace_local_history_stored%3F is very helpfull
Open the CVS view and you should see a filter for local history. You should then be able to right-click on the correct version and Get Contents or do a manual compare and merge. I'm not sure what the eclipse defaults are for keeping local history but there is a decent chance you'll be able to get your stuff back if you act quickly.