“关闭其他” Sublime Text 2中的命令快捷方式 [英] "Close Others" command shortcut in Sublime Text 2
问题描述
我想为关闭其他选项卡添加快捷方式,但似乎找不到命令,这里是我正在尝试:
{keys:[super + alt + w],command:close_others}
Cmd + 选项 + W - 类似 Cmd + < kbd>选项 + H 在OS X中,关闭除当前选项卡以外的所有 $ <$ p
无论如何, close_others
似乎没有做任何事情。我试过 close_other_windows
, close_other_tabs
,没有什么工作。什么是正确的命令呢?
虽然我们在这里,你怎么知道什么命令可用?我的下一个将是 Cmd + 选项 + Shift + W - 向右关闭标签 / p>
有关Sublime窗口管理的一些改进,请参阅关闭所有选项卡,但不在窗口中,在Sublime Text 2
谢谢!
命令是 close_others_by_index
。不幸的是,它接受的参数不能通过简单的键绑定传递。
为了使它工作,你必须创建一个插件。 工具/新插件...
:
import sublime_plugin
pre>
class CloseOthersCommand(sublime_plugin.TextCommand):
def run(self,edit):
window = self.view.window()
group_index ,view_index = window.get_view_index(self.view)
window.run_command(close_others_by_index,{group:group_index,index:view_index})
将它保存在
Packages / User
目录中。然后您可以添加您的键绑定:{keys:[super + alt + w],command :close_others}
关闭右侧的选项卡也是如此。该命令为
close_to_right_by_index
。
插件:
class CloseToRightCommand(sublime_plugin.TextCommand):
def run(self,edit):
$ b window = self.view.window()
group_index,view_index = window.get_view_index(self.view)
window.run_command(close_to_right_by_index,{group:group_index,index:view_index })
键绑定:
{keys:[super + alt + shift + w],command:close_to_right}
I am trying to add a shortcut for "Close Others" tabs, but can't seem to find the command, here is what I am trying:
{ "keys": ["super+alt+w"], "command": "close_others" }
Cmd+Option+W - sort of like Cmd+Option+H in OS X, close all except the current tab, see?
Anyway, close_others
doesn't seem to do anything. I have tried close_other_windows
, close_other_tabs
, nothing works. What is the right command to do that?
And while we're on it, how do you know what commands are available? My next one will be Cmd+Option+Shift+W - "Close Tabs to the Right".
For some improvements in Sublime window management see "Close all tabs, but not the window, in Sublime Text 2"
Thanks!
The command is close_others_by_index
. Unfortunately, it takes arguments that cannot be passed via a simple key binding.
To make it work, you have to create a plugin. Tools/New Plugin...
:
import sublime_plugin
class CloseOthersCommand(sublime_plugin.TextCommand):
def run(self, edit):
window = self.view.window()
group_index, view_index = window.get_view_index(self.view)
window.run_command("close_others_by_index", { "group": group_index, "index": view_index})
Save it in Packages/User
directory. Then you can add your key binding:
{ "keys": ["super+alt+w"], "command": "close_others" }
The same is true for "Close tabs to the right". The command is close_to_right_by_index
.
The plugin:
import sublime_plugin
class CloseToRightCommand(sublime_plugin.TextCommand):
def run(self, edit):
window = self.view.window()
group_index, view_index = window.get_view_index(self.view)
window.run_command("close_to_right_by_index", { "group": group_index, "index": view_index})
The key binding:
{ "keys": ["super+alt+shift+w"], "command": "close_to_right" }
这篇关于“关闭其他” Sublime Text 2中的命令快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!