nickhatboecker / savecopyas Goto Github PK
View Code? Open in Web Editor NEWsave a copy of current file without opening the new file in Sublime Text editor
save a copy of current file without opening the new file in Sublime Text editor
Hi Nick!
Your current Main.sublime-menu
is
[
{
"caption": "File",
"mnemonic": "f",
"id": "file",
"children":
[
{
"caption": "Save Copy As...",
"mnemonic": "k",
"command": "save_copy_as"
}
]
}
]
These mnemonics do not seem to work, and will trigger loads of warnings in the Sublime console (View --> Show Console
)
warning: mnemonic f not found in menu caption File
warning: mnemonic k not found in menu caption Save Copy As...
The mechanism for a Sublime Text main menu mnemonic is that (for Windows only) the main menu will take a letter from the caption (case-sensitive) and underscore it and use the letter as a shortcut to be triggered by alt.
That is, you can only choose from letters S
a
v
e
C
o
p
y
A
s
as your mnemonic for the command save_copy_as
.
And there is no need to assign a mnemonic or even a caption to File
. It's already there. You don't want to override it.
I would like to suggest the change below for Main.sublime-menu
[
{
"id": "file",
"children":
[
{
"caption": "Save Copy As...",
"mnemonic": "p",
"command": "save_copy_as"
}
]
}
]
The exact choice of the letter is up to you, of course.
For your reference, my Sublime Text version is the latest Sublime Text 3, or 3.2.2
(build 3211).
Wouldn't it be better to use the OS' native "save as" dialog, instead of an input panel?
I realize that there is no API to ask the user to choose a file, but wouldn't the following suffice?
import sublime
import sublime_plugin
class SaveCopyAsCommand(sublime_plugin.TextCommand):
def run(self, edit):
previous_path = self.view.file_name()
self.view.run_command('prompt_save_as')
self.view.retarget(previous_path or '')
def is_enabled(self):
return self.view.file_name() is not None
i.e. let ST show it's normal Save As prompt, then set the view back to tracking the original file path
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.