Menu

#524 Save As Next Version

None
closed
nobody
None
1
2013-08-20
2013-08-20
Anonymous
No

Is it possible to have a "Save As Next Version" menu item? This would increment the version number of the currently open file and save the file with the same name but with the incremented number.

For example, currently open file is "Survey v001.tex". Clicking on "Save As Next Version" would automatically save the file as "Survey v002.tex" i.e. it does a "Save As" automatically but also intelligently renames. If the currently open file is not appropriately named e.g. "Survey.tex", it should be saved as "Survey v001.tex".

I like to save my work continuously and prefer to peridocially (few times a day) as a new version, especially when I've made moderate to major changes. Yes, I know it seems lazy but it would help with keeping the "flow" going with my work without having to rename every time I want a new version.

thanks in advance!

Discussion

  • Tim Hoffmann

    Tim Hoffmann - 2013-08-20

    This not a standard functionality and will not implemented into TeXstudio. However, you can achieve these sort of things by user macros. E.g. with the following script.

    Note 1: will only work in future version of TXS, because app.fileSaveAs has not been exposed to scripting (That's fixed now in SVN).
    Note 2: I've used an underscore instead of a space in the example, because it is not recommended for tex file names to contain spaces.
    Note 3: You may consider using a version control system instead, e.g. SVN.

    %SCRIPT
    var fn = editor.fileName();
    
    var regexp = /\_v(\d+).tex$/;
    match = regexp.exec(fn);
    if (match != null) {
        var num = '' + (parseInt(match[1]) + 1);
        while(num.length < 3) {
            num = '0' + num;
        }
        var newName = fn.replace(/\_v\d+.tex$/, '_v' + num + '.tex');
    } else {
        var newName = fn.replace(/.tex$/, '_v000.tex');
    }
    app.fileSaveAs(newName);
    
     

    Last edit: Tim Hoffmann 2013-08-20
  • Tim Hoffmann

    Tim Hoffmann - 2013-08-20
    • status: open --> closed
    • Group: -->
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.