开发工具

sublime 快捷键整理(个人使用习惯)

2016-04-09  本文已影响1183人  清水芦苇

sublime 原生快捷键 —— 不常用但很有用的那些快捷键

sublime 原生快捷键

注意:如果是 mac 中ctrl换为⌘

  1. alt+F3选中所有相同的词汇
  2. 按下鼠标中键来进行垂直方向的纵列选择,也可以进入多重编辑状态。
  3. Ctrl+L 选中整行
  4. Ctrl+Shift+L 在每行行尾插入光标。经常和Ctrl+L、home键配合使用,可同时编辑这些行。
  5. ctrl+F2用于标记一个书签,和F2配合使用。当修改代码行数跨度很大的时候方便通过F2来快速跳跃到另一个修改地点。
    ctrl+shift+F2取消全部书签
    ctrl+alt+F2取消置顶书签
  6. Ctrl + M 在起始括号和结尾括号间切换
  7. Ctrl + Shift + M 快速选择括号间的内容
  8. alt+shift+w 使用标签包裹内容
  9. ctrl+shift+;这会移除与你的光标相关的父标签。对清除标记很有帮助。
  10. alt+shift+↑ 或 ↓ctrl+ ↑ 或 ↓,可微调css中的数值比如12px改为11px。
  11. ctrl+j缩成一行。行当前选中行和下一行缩成一行。
  12. ctrl+k,ctrl+d之后可以跳转到下一个相同单词。
  13. 代码折叠功能。可参考看菜单 edit - code folding【注意mac下面必须选中要折叠的部分】
    ctrl + k,然后按ctrl + 1,可收起所有函数
    ctrl + k, 再按ctrl + j 显示所有函数
    你也可以ctrl + kctrl + 2 (这个数字可以变的,表示收起的函数的级数)

emmet中不常用的标识

  1. $表示从1开始的计数
li.item$*4>a{Item $}

有时间可以继续看看别人是怎么使用sublime的工具用好了提高编码效率,当然这些都是小成。

  1. ctrl+shift+'快速选中光标所在元素的标签名之后,可以快速修改标签名。(注意光标必须在标签名中!)

参考文献

  1. 一个前端程序猿的Sublime Text3的自我修养
    2016.6月内容转载自某博客链接地址已失效。至今由自己不断完善,打造自己个性化的快捷键。

sublime 自定义快捷键整理(个人使用习惯)

插件的某些快捷键会和系统默认或其他插件之间产生冲突,可以根据context来做适配,设定快捷键的使用范围。可见:
Sublime Key Bindings

windows环境

[
    // 删除当前行
    {
        "keys": ["ctrl+d"],
        "command": "run_macro_file",
        "args": {
            "file": "Packages/Default/Delete Line.sublime-macro"
        }
    },
    //plainTask插件中用于标记任务完成
    {
        "keys": ["alt+d"],
        "command": "plain_tasks_complete",
        "context": [{
            "key": "selector",
            "operator": "equal",
            "operand": "text.todo"
        }]
    },
    // 复制选中行到行后
    {
        "keys": ["ctrl+alt+down"],
        "command": "duplicate_line"
    },
    // 选词(按住-继续选择下个相同的字符串)
    {
        "keys": ["ctrl+g"],
        "command": "find_under_expand"
    },
    // 自动提示、补全
    {
        "keys": ["alt+/"],
        "command": "auto_complete"
    }, {
        "keys": ["alt+/"],
        "command": "replace_completion_with_auto_complete",
        "context": [{
            "key": "last_command",
            "operator": "equal",
            "operand": "insert_best_completion"
        }, {
            "key": "auto_complete_visible",
            "operator": "equal",
            "operand": false
        }, {
            "key": "setting.tab_completion",
            "operator": "equal",
            "operand": true
        }]
    },
    // 与上行互换
    {
        "keys": ["alt+up"],
        "command": "swap_line_up"
    },
    // 与下行互换
    {
        "keys": ["alt+down"],
        "command": "swap_line_down"
    }, {
        "keys": ["alt+/", "alt+/"],
        "command": "insert_best_completion"
    },
    //与tab键冲突,秒之
    {
        "keys": ["shift+tab"],
        "command": "insert_best_completion",
        "args": {
            "default": "\t",
            "exact": true
        }
    }, {
        "keys": ["shift+tab"],
        "command": "insert_best_completion",
        "args": {
            "default": "\t",
            "exact": false
        },
        "context": [{
            "key": "setting.tab_completion",
            "operator": "equal",
            "operand": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "replace_completion_with_next_completion",
        "context": [{
            "key": "last_command",
            "operator": "equal",
            "operand": "insert_best_completion"
        }, {
            "key": "setting.tab_completion",
            "operator": "equal",
            "operand": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "reindent",
        "context": [{
            "key": "setting.auto_indent",
            "operator": "equal",
            "operand": true
        }, {
            "key": "selection_empty",
            "operator": "equal",
            "operand": true,
            "match_all": true
        }, {
            "key": "preceding_text",
            "operator": "regex_match",
            "operand": "^$",
            "match_all": true
        }, {
            "key": "following_text",
            "operator": "regex_match",
            "operand": "^$",
            "match_all": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "indent",
        "context": [{
            "key": "text",
            "operator": "regex_contains",
            "operand": "\n"
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "next_field",
        "context": [{
            "key": "has_next_field",
            "operator": "equal",
            "operand": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "commit_completion",
        "context": [{
            "key": "auto_complete_visible"
        }, {
            "key": "setting.auto_complete_commit_on_tab"
        }]
    },
    //移动光标
    {
        "keys": ["alt+l"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": false
        }
    }, {
        "keys": ["alt+r"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": true
        }
    }, {
        "keys": ["alt+u"],
        "command": "move",
        "args": {
            "by": "lines",
            "forward": false
        }
    }, {
        "keys": ["shift+alt+l"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": false,
            "extend": true
        }
    }, {
        "keys": ["shift+alt+r"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": true,
            "extend": true
        }
    }, {
        "keys": ["shift+alt+u"],
        "command": "move",
        "args": {
            "by": "lines",
            "forward": false,
            "extend": true
        }
    }, {
        "keys": ["shift+alt+d"],
        "command": "move",
        "args": {
            "by": "lines",
            "forward": true,
            "extend": true
        }
    },
    //移动光标到行首或行末
    {
        "keys": ["alt+b"],
        "command": "move_to",
        "args": {
            "to": "bol",
            "extend": false
        }
    }, {
        "keys": ["alt+e"],
        "command": "move_to",
        "args": {
            "to": "eol",
            "extend": false
        }
    }, {
        "keys": ["shift+alt+b"],
        "command": "move_to",
        "args": {
            "to": "bol",
            "extend": true
        }
    }, {
        "keys": ["shift+alt+e"],
        "command": "move_to",
        "args": {
            "to": "eol",
            "extend": true
        }
    },
    //滚屏
    {
        "keys": ["alt+g"],
        "command": "scroll_lines",
        "args": {
            "amount": 1.0
        }
    }, {
        "keys": ["alt+h"],
        "command": "scroll_lines",
        "args": {
            "amount": -1.0
        }
    },
    //缩进
    {
        "keys": ["shift+tab"],
        "command": "unindent"
    }, {
        "keys": ["shift+enter"],
        "command": "run_macro_file",
        "args": {
            "file": "res://Packages/Default/Add Line.sublime-macro"
        }
    },
    //切换Side Bar
    {
        "keys": ["ctrl+]"],
        "command": "toggle_side_bar"
    },
    //切换注释
    {
        "keys": ["ctrl+/"],
        "command": "toggle_comment",
        "args": {
            "block": false
        }
    },
    //转到第几行
    // { "keys": ["ctrl+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
    {
        "keys": ["ctrl+p"],
        "command": "show_overlay",
        "args": {
            "overlay": "goto",
            "text": ":"
        }
    },
    //选中整行(系统默认)(转到第几行请用ctrl+p)
    {
        "keys": ["ctrl+l"],
        "command": "expand_selection",
        "args": {
            "to": "line"
        }
    },
    //override termial插件默认配置
    {
        "keys": ["ctrl+shift+t"],
        "command": "reopen_last_file"
    },
    //override termial插件默认配置
    {
        "keys": ["ctrl+shift+t"],
        "command": "reopen_last_file"
    },
    //Emmet插件兼容velocity。还需在Emmet.sublime-settings中添加如下内容
    //"vm":{
    //  "extends":"html",
    //  "profiles":"vm"
    // }
    {
        "keys": [
            "tab"
        ],
        "command": "expand_abbreviation_by_tab",
        "context": [{
            "operand": "source.css, source.sass, source.less, source.scss, source.stylus, source.postcss, source.velocity,source.jade, text.jade, text.slim, text.xml, text.html - source, text.haml, text.scala.html, source string, text.html.basic",
            "operator": "equal",
            "match_all": true,
            "key": "selector"
        }, {
            "operand": "storage.type.templatetag.django",
            "operator": "not_equal",
            "match_all": true,
            "key": "selector"
        }, {
            "match_all": true,
            "key": "selection_empty"
        }, {
            "operator": "equal",
            "operand": false,
            "match_all": true,
            "key": "has_next_field"
        }, {
            "operator": "equal",
            "operand": false,
            "match_all": true,
            "key": "setting.disable_tab_abbreviations"
        }, {
            "operand": false,
            "operator": "equal",
            "match_all": true,
            "key": "auto_complete_visible"
        }, {
            "match_all": true,
            "key": "is_abbreviation"
        }]
    },
    // Table Editor快捷键 start
    {
        "keys": ["tab"],
        "command": "table_editor_next_field",
        "context": [{
            "key": "setting.enable_table_editor",
            "operator": "equal",
            "operand": true,
            "match_all": true
        }, {
            "key": "preceding_text",
            "operator": "regex_contains",
            "operand": "^\\s*\\|",
            "match_all": true
        }, {
            "key": "following_text",
            "operator": "regex_contains",
            "operand": "$",
            "match_all": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "table_editor_previous_field",
        "context": [{
            "key": "setting.enable_table_editor",
            "operator": "equal",
            "operand": true,
            "match_all": true
        }, {
            "key": "preceding_text",
            "operator": "regex_contains",
            "operand": "^\\s*\\|",
            "match_all": true
        }, {
            "key": "following_text",
            "operator": "regex_contains",
            "operand": "$",
            "match_all": true
        }]
    },
    //Table Editor快捷键 end
    { "keys": ["ctrl+r"], "command": "goto_definition" },
]

==========================================================================================================================

Mac环境

[
    // 删除当前行
    {
        "keys": ["super+d"],
        "command": "run_macro_file",
        "args": {
            "file": "Packages/Default/Delete Line.sublime-macro"
        }
    },
    //plainTask插件中用于标记任务完成
    {
        "keys": ["alt+d"],
        "command": "plain_tasks_complete",
        "context": [{
            "key": "selector",
            "operator": "equal",
            "operand": "text.todo"
        }]
    },
    // 复制选中行到行后
    {
        "keys": ["super+alt+down"],
        "command": "duplicate_line"
    },
    // 选词(按住-继续选择下个相同的字符串)
    {
        "keys": ["super+g"],
        "command": "find_under_expand"
    },
    // 自动提示、补全
    {
        "keys": ["alt+/"],
        "command": "auto_complete"
    }, {
        "keys": ["alt+/"],
        "command": "replace_completion_with_auto_complete",
        "context": [{
            "key": "last_command",
            "operator": "equal",
            "operand": "insert_best_completion"
        }, {
            "key": "auto_complete_visible",
            "operator": "equal",
            "operand": false
        }, {
            "key": "setting.tab_completion",
            "operator": "equal",
            "operand": true
        }]
    },
    // 与上行互换
    {
        "keys": ["alt+up"],
        "command": "swap_line_up"
    },
    // 与下行互换
    {
        "keys": ["alt+down"],
        "command": "swap_line_down"
    }, {
        "keys": ["alt+/", "alt+/"],
        "command": "insert_best_completion"
    },
    //与tab键冲突,秒之
    {
        "keys": ["shift+tab"],
        "command": "insert_best_completion",
        "args": {
            "default": "\t",
            "exact": true
        }
    }, {
        "keys": ["shift+tab"],
        "command": "insert_best_completion",
        "args": {
            "default": "\t",
            "exact": false
        },
        "context": [{
            "key": "setting.tab_completion",
            "operator": "equal",
            "operand": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "replace_completion_with_next_completion",
        "context": [{
            "key": "last_command",
            "operator": "equal",
            "operand": "insert_best_completion"
        }, {
            "key": "setting.tab_completion",
            "operator": "equal",
            "operand": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "reindent",
        "context": [{
            "key": "setting.auto_indent",
            "operator": "equal",
            "operand": true
        }, {
            "key": "selection_empty",
            "operator": "equal",
            "operand": true,
            "match_all": true
        }, {
            "key": "preceding_text",
            "operator": "regex_match",
            "operand": "^$",
            "match_all": true
        }, {
            "key": "following_text",
            "operator": "regex_match",
            "operand": "^$",
            "match_all": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "indent",
        "context": [{
            "key": "text",
            "operator": "regex_contains",
            "operand": "\n"
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "next_field",
        "context": [{
            "key": "has_next_field",
            "operator": "equal",
            "operand": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "commit_completion",
        "context": [{
            "key": "auto_complete_visible"
        }, {
            "key": "setting.auto_complete_commit_on_tab"
        }]
    },
    //移动光标
    {
        "keys": ["alt+l"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": false
        }
    }, {
        "keys": ["alt+r"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": true
        }
    }, {
        "keys": ["alt+u"],
        "command": "move",
        "args": {
            "by": "lines",
            "forward": false
        }
    }, {
        "keys": ["shift+alt+l"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": false,
            "extend": true
        }
    }, {
        "keys": ["shift+alt+r"],
        "command": "move",
        "args": {
            "by": "characters",
            "forward": true,
            "extend": true
        }
    }, {
        "keys": ["shift+alt+u"],
        "command": "move",
        "args": {
            "by": "lines",
            "forward": false,
            "extend": true
        }
    }, {
        "keys": ["shift+alt+d"],
        "command": "move",
        "args": {
            "by": "lines",
            "forward": true,
            "extend": true
        }
    },
    //移动光标到行首或行末
    {
        "keys": ["alt+b"],
        "command": "move_to",
        "args": {
            "to": "bol",
            "extend": false
        }
    }, {
        "keys": ["alt+e"],
        "command": "move_to",
        "args": {
            "to": "eol",
            "extend": false
        }
    }, {
        "keys": ["shift+alt+b"],
        "command": "move_to",
        "args": {
            "to": "bol",
            "extend": true
        }
    }, {
        "keys": ["shift+alt+e"],
        "command": "move_to",
        "args": {
            "to": "eol",
            "extend": true
        }
    },
    //滚屏
    {
        "keys": ["alt+g"],
        "command": "scroll_lines",
        "args": {
            "amount": 1.0
        }
    }, {
        "keys": ["alt+h"],
        "command": "scroll_lines",
        "args": {
            "amount": -1.0
        }
    },
    //缩进
    {
        "keys": ["shift+tab"],
        "command": "unindent"
    }, {
        "keys": ["shift+enter"],
        "command": "run_macro_file",
        "args": {
            "file": "res://Packages/Default/Add Line.sublime-macro"
        }
    },
    //切换Side Bar
    {
        "keys": ["super+]"],
        "command": "toggle_side_bar"
    },
    //切换注释
    {
        "keys": ["super+/"],
        "command": "toggle_comment",
        "args": {
            "block": false
        }
    },
    //转到第几行
    // { "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
    {
        "keys": ["super+p"],
        "command": "show_overlay",
        "args": {
            "overlay": "goto",
            "text": ":"
        }
    },
    //选中整行(系统默认)(转到第几行请用super+p)
    {
        "keys": ["super+l"],
        "command": "expand_selection",
        "args": {
            "to": "line"
        }
    },
    //override termial插件默认配置
    {
        "keys": ["super+shift+t"],
        "command": "reopen_last_file"
    },
    //override termial插件默认配置
    {
        "keys": ["super+shift+t"],
        "command": "reopen_last_file"
    },
    //Emmet插件兼容velocity。还需在Emmet.sublime-settings中添加如下内容
    //"vm":{
    //  "extends":"html",
    //  "profiles":"vm"
    // }
    {
        "keys": [
            "tab"
        ],
        "command": "expand_abbreviation_by_tab",
        "context": [{
            "operand": "source.css, source.sass, source.less, source.scss, source.stylus, source.postcss, source.velocity,source.jade, text.jade, text.slim, text.xml, text.html - source, text.haml, text.scala.html, source string, text.html.basic",
            "operator": "equal",
            "match_all": true,
            "key": "selector"
        }, {
            "operand": "storage.type.templatetag.django",
            "operator": "not_equal",
            "match_all": true,
            "key": "selector"
        }, {
            "match_all": true,
            "key": "selection_empty"
        }, {
            "operator": "equal",
            "operand": false,
            "match_all": true,
            "key": "has_next_field"
        }, {
            "operator": "equal",
            "operand": false,
            "match_all": true,
            "key": "setting.disable_tab_abbreviations"
        }, {
            "operand": false,
            "operator": "equal",
            "match_all": true,
            "key": "auto_complete_visible"
        }, {
            "match_all": true,
            "key": "is_abbreviation"
        }]
    },
    // Table Editor快捷键 start
    {
        "keys": ["tab"],
        "command": "table_editor_next_field",
        "context": [{
            "key": "setting.enable_table_editor",
            "operator": "equal",
            "operand": true,
            "match_all": true
        }, {
            "key": "preceding_text",
            "operator": "regex_contains",
            "operand": "^\\s*\\|",
            "match_all": true
        }, {
            "key": "following_text",
            "operator": "regex_contains",
            "operand": "$",
            "match_all": true
        }]
    }, {
        "keys": ["shift+tab"],
        "command": "table_editor_previous_field",
        "context": [{
            "key": "setting.enable_table_editor",
            "operator": "equal",
            "operand": true,
            "match_all": true
        }, {
            "key": "preceding_text",
            "operator": "regex_contains",
            "operand": "^\\s*\\|",
            "match_all": true
        }, {
            "key": "following_text",
            "operator": "regex_contains",
            "operand": "$",
            "match_all": true
        }]
    },
    //Table Editor快捷键 end
    { "keys": ["super+r"], "command": "goto_definition" },
]
上一篇 下一篇

猜你喜欢

热点阅读