[英]Importing default sublime text commands into a custom command
I'm writing a command that needs to copy the current file's path. 我正在写一个需要复制当前文件路径的命令。 Sublime Text already has a copy_path command that achieves this. Sublime Text已经具有copy_path命令来实现此目的。 Is it possible to import that command into my command's file? 可以将该命令导入到我的命令文件中吗? I have tried import copy_path
and import CopyPathCommand
. 我尝试了import copy_path
和import CopyPathCommand
。 I have also tried calling the command as if it were a method on the sublime
module, ie sublime.copy_path()
but all of these attempts have resulted in errors. 我也尝试过调用命令,就好像它是sublime
模块上的方法,即sublime.copy_path()
但是所有这些尝试都导致了错误。
To import the command you can write from Default.copy_path import CopyPathCommand
. 要导入命令,可以from Default.copy_path import CopyPathCommand
。 However it sounds as if you run the command for which you don't need to import it. 但是 ,听起来好像您在运行不需要为其导入命令的命令。 Just write self.view.run_command("copy_path")
inside your TextCommand
and it will be executed. 只需在TextCommand
内写入self.view.run_command("copy_path")
TextCommand
执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.