Home Download Buy Blog Forum Support

Save Copy As

Save Copy As

Postby messa on Thu Jul 19, 2012 8:36 pm

Hello,

I am hoping this would be a simple and highly sought after feature that could be implemented.

Coming from Notepad++ the "Save Copy As" in the file menu is an excellent way to quickly make a backup copy of a file before you lay down a bunch of new changes to it.
At least that's been my work flow.

The alternative is to "Save As" which is brutal for what I'm trying to accomplish. The file saves with the new name and then reopens under that new name. If you're saving a backup you don't need that file open. You want to stay in the same file.

I can't be alone on this one right?
I did use the search first.

Thank you
messa
 
Posts: 4
Joined: Thu Jul 19, 2012 8:30 pm

Re: Save Copy As

Postby Xavura on Fri Jul 20, 2012 12:20 am

You may want to look into something called version control. I would recommend Git.
Xavura
 
Posts: 19
Joined: Sat Jul 14, 2012 4:40 pm

Re: Save Copy As

Postby messa on Fri Jul 20, 2012 3:04 am

Hi,

Thanks for the suggestion.

It looks overly complicated to me. I've looked at some tutorials to set it up and this is what I see.
You have to go into terminal each time and type a command to take a new snapshot.
No great way to see old versions. Looks like I would view these in terminal or gitk.
I found a nice guide here though (for anyone who is interested) http://sixrevisions.com/web-development ... ol-system/

With "Save a Copy As" I just hit that and append "-Backup001" then save.
I'm still in the file I was working in and clearly have a backup file I can see and get back into easily.
If I really need to compare changes I just use the compare file tool and can see changes side by side rather than being told one text item that was changed in terminal and not seeing either file.
It does get a little messy if you have a lot of them and you need to do some house keeping every now and then. But way simpler and more at your finger tips than git looks to be.

If a plugin could be coded that would be even better.
To have some configurations like selecting a path to save backups and a keyboard shortcut to take a snapshot.
Also, an easy way to view old snapshots and compare and/or restore.
Now that would be nice!
messa
 
Posts: 4
Joined: Thu Jul 19, 2012 8:30 pm

Re: Save Copy As

Postby messa on Tue Jul 24, 2012 4:32 pm

There is a feature request in for this through the preferred tracking system for SublimeText 2.

If you would like to see this included please go there and comment and rate it UP.

http://sublimetext.userecho.com/topic/1 ... ve-a-copy/
messa
 
Posts: 4
Joined: Thu Jul 19, 2012 8:30 pm

Re: Save Copy As

Postby jbjornson on Mon Aug 27, 2012 9:37 am

Here is an initial attempt at a plugin for this. Any comments or corrections would be appreciated.

Unfortunately I have very limited access to github from work, so I had to post the plugin as a gist:
https://gist.github.com/3486921

------------
Description:
------------

Plugin to backup a file (or even an unsaved view). If the current view has unsaved changes
then the backup will include these unsaved changes. This should be cross platform but has
only been tested on windows.

The plugin has three modes: "backup", "view" and "diff".
- backup : Backs up the file to the location defined by the settings. A file
will only be backed up if there are differences when compared to
the most recent backup.
- view : Shows a quick panel with the saved backups of the current file.
The selected backup is opened.
- diff : Shows a quick panel with the saved backups of the current file.
The selected backup is compared with the current file and the
resulting diff is displayed.

---------
Settings:
---------

The supported settings are:
- default_unsaved_view_name : The default filename to use for an unsaved view with no title
- backup_prefix : Appended to the end of the name of the file being backed up
- backup_timestamp_mask : Timestamp to append after the backup_prefix (1)
- backup_dir_style :
backup-exploded - the directory tree from the source file is recreated
under the folder specified in the backup_dir setting
(eg c:\data\file.txt -> c:\backup\c\data\file.txt-Backup_2012-08-27_...)
backup-flat - directly in the folder specified in the backup_dir setting
(eg c:\data\file.txt -> c:\backup\file.txt-Backup_2012-08-27_...)
inline - in the same directory as the file being backed up
(eg c:\data\file.txt -> c:\data\file.txt-Backup_2012-08-27_...)
- backup_dir : Where the backups should be stored
(ignored if backup_dir_style=inline is used)

(1) The backup filenames are used to discover which file contains the most recent backup,
so the backup_timestamp_mask settings should ensure sortability
(eg "yyyy-mm-dd" is ok, but "dd-mm-yyyy" is not)

The plugin will attempt to load settings from "BackupFile.sublime-settings".

-------------
Key Bindings:
-------------

{ "keys": ["alt+e", "alt+b"], "command": "backup_file", "args": {"mode" : "backup"}}
{ "keys": ["alt+e", "alt+v"], "command": "backup_file", "args": {"mode" : "view"}}
{ "keys": ["alt+e", "alt+d"], "command": "backup_file", "args": {"mode" : "diff"}}

-----
TODO:
-----
- There are some issues with handling umlaut characters and I'm not sure how to fix this.
- If a backup fails on an existing file with unsaved changes, any subsequent backups (before saving)
will result if the filename being lost (and therefore the default_unsaved_view_name being used).
It looks like Sublime return null from self.view.file_name(), so I'm not sure how to fix this.
- Is it possible to get the default extension for an unsaved view from the syntax definition?
- Confirm this works on Linix and Macs
jbjornson
 
Posts: 347
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Save Copy As

Postby bizoo on Mon Aug 27, 2012 10:29 am

bizoo
 
Posts: 876
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Save Copy As

Postby jbjornson on Mon Aug 27, 2012 12:44 pm



Thanks bizoo. Package manager is blocked by my work proxy so I'm a bit uninformed with what is available there. Since nobody mentioned any alternatives when this was first asked I figured it might be fun to have a crack at it. I'd suggest that people use the solutions linked to by bizzo above before trying mine.
jbjornson
 
Posts: 347
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Save Copy As

Postby ReinierK on Mon Aug 27, 2012 2:26 pm

If you install the sidebarenhancements plugin manually, you can duplicate files and specify a new name. The file will still be opened after that, but you can simply close it and work on the original file.
ReinierK
 
Posts: 23
Joined: Fri Aug 24, 2012 8:27 pm

Re: Save Copy As

Postby messa on Wed Oct 17, 2012 6:19 pm

Thanks jbjornson. I'll give that a try.

Local History looks very nice. Lots of the features I was looking for but it's a little too application specific (maybe that's unavoidable) and I really try to avoid that stuff if possible. Because what happens if you don't have sublimetext 2 or have to move the project?

A lot of times the simplest things work best. A "Save a Copy As" is just fast and simple.
messa
 
Posts: 4
Joined: Thu Jul 19, 2012 8:30 pm

Re: Save Copy As

Postby theskyliner on Tue Aug 05, 2014 9:31 pm

I know this is a really old topic, but it's the first result on google about this topic and I finally wrote a plugin for this function.
You can find it on gitHub: https://github.com/theskyliner/SaveCopyAs/
theskyliner
 
Posts: 1
Joined: Tue Aug 05, 2014 9:30 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Google [Bot] and 7 guests