有没有办法在 sublime 3 中显示和搜索所有配置的键盘快捷键?
Is there a way to display and search all configured keyboard shortcuts in sublime 3?
我在 sublime text 3 中确实缺少两个功能:
- 功能齐全的集成终端 - 就像在 geany 中一样(是的,我知道
Glue
但它不像普通终端那样运行)
- 可搜索 显示所有当前活动的、已配置的键盘快捷键 所有包 短描述和包名。
虽然我可以在没有前者的情况下生活(但很想得到这方面的评论),但我怀疑有一些功能或用户 script/plugin 可以实现后者。我就是找不到任何东西。我真的厌倦了查看许多数据包的相当神秘的文本配置文件,只是为了找出快捷方式被另一个包的快捷方式覆盖。想帮忙吗?
关于所有当前活动的键盘快捷键的可搜索显示,您可以轻松创建一个插件来执行此操作:
- 从
Tools
菜单 -> Developer
-> New Plugin
将模板内容替换为以下内容:
import sublime, sublime_plugin
class ShowMappedKeysCommand(sublime_plugin.TextCommand):
def run(self, edit):
files = sublime.find_resources('*.sublime-keymap')
items = []
for file in files:
contents = sublime.load_resource(file)
mapped = sublime.decode_value(contents)
for mapping in mapped:
items.append((file, mapping['keys'], mapping['command']))
self.view.window().run_command('new_file')
view = self.view.window().active_view()
view.insert(edit, 0, '\n'.join(repr(item) for item in items))
将其保存在默认文件夹中,将其命名为 show_mapped_keys.py
然后你可以将一个键映射到新创建的 show_mapped_keys
命令,或者直接从 Sublime 控制台执行它(View
菜单 -> Show Console
-> sublime.active_window().active_view().run_command('show_mapped_keys')
)
这将创建一个新选项卡,其中包含所有活动配置的键盘绑定的列表,显示它的定义位置(即它所属的包或您的用户键绑定文件),键是什么,以及键绑定将执行的命令的名称。然后可以正常搜索。
显然,如果存在冲突,这不会显示哪个优先。找出答案的一种方法是在尝试相关的键绑定之前在控制台中执行 sublime.log_commands(True)
,然后查看执行了哪个命令。
虽然 Keith Hall 的 works well enough, there's already a plugin in Package Control that has numerous features: FindKeyConflicts
by skuroda. You can search for all key maps, all conflicts, direct conflicts, overlap conflicts, single package conflicts (all within one package), and a very useful one: multiple package conflicts, where you can choose the packages you suspect are conflicting and test only them. This is great for when you have packages like LaTeXTools or Emmet 安装了大约一百万个组合键(没有冒犯他们,我喜欢这些软件包),但你知道问题不在那里。
我在 sublime text 3 中确实缺少两个功能:
- 功能齐全的集成终端 - 就像在 geany 中一样(是的,我知道
Glue
但它不像普通终端那样运行) - 可搜索 显示所有当前活动的、已配置的键盘快捷键 所有包 短描述和包名。
虽然我可以在没有前者的情况下生活(但很想得到这方面的评论),但我怀疑有一些功能或用户 script/plugin 可以实现后者。我就是找不到任何东西。我真的厌倦了查看许多数据包的相当神秘的文本配置文件,只是为了找出快捷方式被另一个包的快捷方式覆盖。想帮忙吗?
关于所有当前活动的键盘快捷键的可搜索显示,您可以轻松创建一个插件来执行此操作:
- 从
Tools
菜单 ->Developer
->New Plugin
将模板内容替换为以下内容:
import sublime, sublime_plugin class ShowMappedKeysCommand(sublime_plugin.TextCommand): def run(self, edit): files = sublime.find_resources('*.sublime-keymap') items = [] for file in files: contents = sublime.load_resource(file) mapped = sublime.decode_value(contents) for mapping in mapped: items.append((file, mapping['keys'], mapping['command'])) self.view.window().run_command('new_file') view = self.view.window().active_view() view.insert(edit, 0, '\n'.join(repr(item) for item in items))
将其保存在默认文件夹中,将其命名为
show_mapped_keys.py
然后你可以将一个键映射到新创建的 show_mapped_keys
命令,或者直接从 Sublime 控制台执行它(View
菜单 -> Show Console
-> sublime.active_window().active_view().run_command('show_mapped_keys')
)
这将创建一个新选项卡,其中包含所有活动配置的键盘绑定的列表,显示它的定义位置(即它所属的包或您的用户键绑定文件),键是什么,以及键绑定将执行的命令的名称。然后可以正常搜索。
显然,如果存在冲突,这不会显示哪个优先。找出答案的一种方法是在尝试相关的键绑定之前在控制台中执行 sublime.log_commands(True)
,然后查看执行了哪个命令。
虽然 Keith Hall 的 FindKeyConflicts
by skuroda. You can search for all key maps, all conflicts, direct conflicts, overlap conflicts, single package conflicts (all within one package), and a very useful one: multiple package conflicts, where you can choose the packages you suspect are conflicting and test only them. This is great for when you have packages like LaTeXTools or Emmet 安装了大约一百万个组合键(没有冒犯他们,我喜欢这些软件包),但你知道问题不在那里。