跳至内容

命令面板

命令面板通过 .sublime-commands 文件获取条目。

文件格式

以下是 Packages/Default/Default.sublime-commands 的摘录

json
[
    { "caption": "Project: Save As", "command": "save_project_and_workspace_as" },
    { "caption": "Project: Close", "command": "close_workspace" },
    { "caption": "Project: Add Folder", "command": "prompt_add_folder" },

    {
        "caption": "Preferences: Settings",
        "command": "edit_settings", "args":
        {
            "base_file": "${packages}/Default/Preferences.sublime-settings",
            "default": "// Settings in here override those in \"Default/Preferences.sublime-settings\",\n// and are overridden in turn by syntax-specific settings.\n{\n\t$0\n}\n"
        }
    },

    { "caption": "Preferences: Browse Packages", "command": "open_dir", "args": {"dir": "$packages"} },

    { "caption": "Permute Lines: Reverse", "command": "permute_lines", "args": {"operation": "reverse"} },
    { "caption": "Permute Lines: Unique", "command": "permute_lines", "args": {"operation": "unique"} },
    { "caption": "Permute Lines: Shuffle", "command": "permute_lines", "args": {"operation": "shuffle"} },
]

caption : 在命令面板中显示的文本。

command : 要执行的命令。

args : 传递给 command 的参数。

请注意,特殊的类似片段的变量 ${packages} 仅由某些 :command: 命令解释。

如何使用命令面板

  1. 按下 Ctrl  P
  2. 选择命令

条目会根据当前上下文进行过滤。并非所有条目始终可见。