sublime text自定义快捷键

菜单栏Preferences-->Key Binding,打开,在右侧进行用户配置,格式跟左侧类似:

[
    { "keys": ["ctrl+shift+n"], "command": "new_window" },
    { "keys": ["alt+o"], "command": "switch_file", "args": {"extensions": ["cpp", "cxx", "cc", "c", "hpp", "hxx", "hh", "h", "ipp", "inl", "m", "mm"]} },
...

]

"Keys"即为设置的快捷键,“command”为需要执行的命令名称,“args”为相应命令所需要的参数,具体参数根据所执行的命令需求确定。

此处以markdown浏览器中预览命令为例,未设置快捷键时,需要shift+ctrl+p调出命令面板后输入Markdown Preview: Preview in Browser确认后并选择markdown选项(也可以选择github,可以支持在线资源的预览)即可在浏览器中显示md文件预览效果。

若使用快捷键,对应上述格式,“Keys”为自定义,“command”即为markdown_preview,与安装的包名相关,而“args”项则跟包的配置setting有关,打开路径为Preferences-->Package Setting-->Markdown Preview-->Setting,即可对参数进行设置,部分参数如下:

{
    /*
        Sets the default opener for HTML files

        default - Use the system default HTML viewer
        other - Set a full path to any executable. ex: /Applications/Google Chrome Canary.app or /Applications/Firefox.app
    */
    "browser": "default",

    /*
        Sets the parser used for building markdown to HTML.

        NOTE: The parser setting is not for the preview commands.
        The previews have separate commands for each parser markdown.

        Warning for github API: if you have a ST2 linux build, Python is not built with SSL so it may not work

        default - The current default parser is python-markdown parser.
        markdown - Use the built-in python-markdown parser
        github - Use the github API to convert markdown, so you can use GitHub flavored Markdown, see https://help.github.com/articles/github-flavored-markdown/
        gitlab - Use the gitlab API to convert markdown, so you can use GitLab flavored Markdown, see https://docs.gitlab.com/ee/user/markdown.html
    */
    "parser": "markdown", 

...

可以配置参数“parser”为“markdown”进行本地资源预览,因此快捷键用户配置命令即为:

[

...

{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"parser":"markdown"} }

]

其他快捷键按此过程设置即可。

你可能感兴趣的:(blog)