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

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" },
]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,847评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,208评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,587评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,942评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,332评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,587评论 1 218
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,853评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,568评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,273评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,542评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,033评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,373评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,031评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,073评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,830评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,628评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,537评论 2 269

推荐阅读更多精彩内容