Sublime Forum

Many Problems with Save Copy As

#1

This was in ideas and future requests, but as I’m having various issues with ST3, I though i’d get stuck into them all.

If you don’t want to read any moaning pls skip the following paragraph

MOAN***************
As a general point I seem to be spending a lot of time ‘fixing’ ST3. It’s a shame having been really impressed at the beginning, not being able to resolve some simple issues is becoming an issue. I want to be supportive, but is it saving me time when I’m spending 15% of my work on this forum trying to get solutions?
Solutions often, but not always, involve programming. It’s like linux (which i like, it took a few years, they don’t ask you for cash !)
It’s a tricky one, at the beginning i was ready to hand other some cash. Now it’s not the case.
MOAN OVER*****
So onwards

I can’t get a Save Copy As to work. I installed Save Copy As:

“Sace Copy as” I can’t get to work. It says “Save file first”, I save file, select “Sace Copy as” and it says “Save file first”.

I tried the command line plugin, (theskyliner) but that means you can’t see what the previous names of your files are, so that doesn’t help me.

I thought I had a brain wave, “save as”, crtl + w, then ctr+shift+t, but of course it just opens the last file. I don’t remember having this trouble with pluma, the standard text editor that come with linux mint, but that was a while a go.

Then I tried multi-command (after installing it) and tried using this keybinding (it’s missing the save as I know) just as a test and work around, it doesn’t work either.

{
“keys”: [
“alt+shift+s”
],
“command”: “run_multiple_commands”,
“args”: {
“commands”: [
{
“command”: “select_all”
},
{
“command”: “copy”
},
{
“command”: “new_file”
},
{
“command”: “paste”
}
]
}
},

Any help much appreciated.

0 Likes

Moving from 'dialog box' to 'panel' without the mouse
#2

I could only find one Multicommand plugin on Package Control and it works fine for your case. Here’s the keybinding I tried :

{"keys": ["ctrl+r", "ctrl+y"], "command": "multicommand", "args": {
		"commands": [
			{
				"command": "select_all",
			},
			{
				"command": "copy",
			},
			{
				"command": "new_file",
			},
			{
				"command": "paste",
			},
			{
				"command": "save",
			}
		]
	},}

One difference is your top level command should be multicommand & not run_multiple_commands. Pressing the said binding prompts you to save a copy of the currently open file.

0 Likes

#3

Whoooo hooo !!!

{
“keys”: [
“alt+shift+s”
],
“command”: “multicommand”,
“args”: {
“commands”: [
{
“command”: “select_all”
},
{
“command”: “copy”
},
{
“command”: “new_file”
},
{
“command”: “paste”
},
{
“command”: “prompt_save_as”
},
{
“command”: “close”
}
]
}
},

(sorry there doesn’t seem to be any indentation, it shows it in my box but not the preview)

That above keybinding is a work around for save a copy as. The multicommand plugin needs installing !

Thanks very much to Ultra. Finally ! (I’m sooo excited)

I’ll see if i can find the solved button…

Lozminda

:grinning::sparkling_heart::boom::clap:

Ps It’d be nice to somehow unselect after copying, so that when you go back to your original file everything isn’t selected. It’s only a move of the cursor to deselect. I tried sticking the “command:down” in, but to no avail. It’d save a key press and therefore save some keyboard wear and tear ! Saving the environment one key press at a time…

0 Likes

#4

Well, if you wouldn’t mind a bit of plugin code, the following plugin also does the same as “Save Copy As” & gets rid of your “unselect after copying” also. (I guess you could somehow do it through keyboard and I am maybe complicating it too much but then I have never been much of a keyboard guy before).

import sublime
import textwrap
import sublime_plugin

class SaveCopyAsCommand(sublime_plugin.WindowCommand):

	def run(self):
		view_content = self.window.active_view().substr(sublime.Region(0, self.window.active_view().size()))
		new_file = self.window.new_file()
		new_file.run_command("insert_snippet", {
			"contents": textwrap.dedent(view_content).lstrip()
		})
		new_file.run_command("save")

You have to save this file as a python (.py) file in the User directory (go to Preferences -> Browse Packages... to go to the User directory).

Then set up a keybinding for this command

{ "keys": ["ctrl+e", "ctrl+r"], "command": "save_copy_as" }

and you should be good to go.

0 Likes

#5

Thanks very much for your efforts, I’m not quite at installing bits of Python yet.
I did however tak this bit on to the end of my command list (after command close):

{“command”: “move”, “args”: {“by”: “characters”, “forward”: false}}

and that gets rid of the select all, so it all ends up doing exactly as I want. I get to see a list of files while saving, and I don’t have to open or close anything.
Again Ultra, cheers

A Final Note, Possibly

If someone else is using this, what is essentially a hack, for the “select all” and “copy” etc commands to work, the cursor has to be on the tab you want to save as (not, say, in the find bar below or some other part of ST3) other wise it won’t work and you’ll have a file save of 0 bytes. So the code is no doubt better…

0 Likes