How to use File : duplicate
option from the palette using plugin in sublime text ?
In order to see which command is being run when a particular action is being performed, open the console (Ctrl`) and run
sublime.log_commands(True)
Next, open the Command Palette (command: show_overlay {"overlay": "command_palette"}
will show up in the console) and select File: Duplicate
. The console will close, but when you reopen it you will see that command: side_bar_duplicate {}
has been logged. At this point, you can enter
sublime.log_commands(False)
to stop logging, as it tends to fill the console with unnecessary garbage.
As you can see from the name of the command, File: Duplicate
is from the SideBarEnhancements
plugin (defined here) and is not built-in to Sublime. Therefore, if you are making a plugin for public distribution, you users will need to have SideBarEnhancements installed first.
To call this (or any) command in your plugin, simply put
window.run_command("side_bar_duplicate")
into your code at the appropriate location.
As @OdatNurd reminded me, because SideBarDuplicateCommand
is a subclass of sublime_plugin.WindowCommand
, it can only be run on an instance of sublime.Window
.