Skip to content

Instantly share code, notes, and snippets.

@xianghongai
Last active September 26, 2024 00:59
Show Gist options
  • Save xianghongai/82dc267edba66801d198a828584819fb to your computer and use it in GitHub Desktop.
Save xianghongai/82dc267edba66801d198a828584819fb to your computer and use it in GitHub Desktop.
Sublime Text Sync Settings

Sublime Text 3

可用 Sublime Text 3/EmEditor 快速打开各类文本大文件

扩展

安装扩展:菜单 Preferences > Package ControlCtrl+Shift+P 输入 Package Control: Install Package (pcip),搜索并安装。

扩展中心:Package Control:管理扩展。

设置代理:Preferences > Package Setting > Package Control,设置 http_proxy

快捷键

快捷键 说明 按键有变更
Alt+Z 自动换行 自定义,Z,折来折去,形象化
Ctrl+Shift+P 命令面板 (几乎所有编辑器都参考了这个快捷键,包含浏览器)
Ctrl+P 跳转到文件 (影响力同上)
Ctrl+D 依次选中下一个相同的匹配项 (影响力同上)
Ctrl+Enter 快速插入新行,在下方 (影响力同上)
Ctrl+Shift+Enter 快速插入新行,在上方 (影响力同上)
Ctrl+L 行选择 (向下) (Line)
Alt+L 行选择 (向上)
Ctrl+K+F 格式化代码 (Format) 否,内置 (Selection > Format),最早由 Visual Studio 引入
Ctrl+Shift+L 列模式 (已选择行)
Ctrl+Shift+K 删除行
Ctrl+J 合并选择内容 (Join) 是,有语义助记
Alt+↑ 移动 (上移) 是,与 VS Code 保持一致 (不用考虑选中,支持光标位置)
Alt+↓ 移动 (下移) 是,与 VS Code 保持一致
Alt+Shift+↑/↓ 再制选择内容
Ctrl+Shift+↑/↓ 将上方或下方的行添加到选择中
Ctrl+K+K 书签创建/删除 (Bookmark) 是,有语义助记
Ctrl+K+P 书签跳转,上一个 (Bookmark Prev) 是,有语义助记
Ctrl+K+N 书签跳转,下一个 (Bookmark Next) 是,有语义助记
Ctrl+K+C 书签,清除 (Bookmark Clear) 是,有语义助记
Ctrl+K+1 ... 9 折叠第 1, 2 ... 9 层级
Ctrl+K+0 / Ctrl+K+J 展开所有层级
Ctrl+K+T 折叠 HTML/XML 标签属性
Ctrl+Shift+[ 折叠
Ctrl+Shift+] 展开
Alt+0 聚焦最后一个编辑器 是,与 VS Code 保持一致
Alt+1 ... 9 聚焦第 1, 2 ... 9 编辑器
Ctrl+0 聚焦侧边栏
Ctrl+1 ... 9 聚焦第 1, 2 ... 8 编辑器分组
Alt+Shift+O 向外扩展选择 (Outward) 是,有语义助记
Alt+Shift+A 向外自动扩展选择 (Automatic) 是,有语义助记
Alt+Shift+( 选择括号内部 是,有语义助记
Alt+Shift+T 选择 HTML/XML 标签内部 (Tag) 是,有语义助记
Ctrl+\ 编辑器分组 (新建)
Ctrl+Shift+\ 编辑器分组 (撤销)
Alt+Shift+PageUp ‘编辑器’移动 (前一组)
Alt+Shift+PageDown ‘编辑器’移动 (后一组)

配置入口:菜单 Preferences > Key Bindings

[
  // 转换变更命名风格
  {
    "keys": ["ctrl+u","ctrl+s"],
    "command": "convert_ident_case",
    "args": {
      "case": "lower",
      "separator": "_"
    }
  },
  {
    "keys": ["ctrl+u","ctrl+k"],
    "command": "convert_ident_case",
    "args": {
      "case": "lower",
      "separator": "-"
    }
  },
  {
    "keys": ["ctrl+u","ctrl+c"],
    "command": "convert_ident_case",
    "args": {
      "case": "title",
      "first_case": "lower"
    }
  },
  {
    "keys": ["ctrl+u","ctrl+p"],
    "command": "convert_ident_case",
    "args": {
      "case": "title"
    }
  },
  {
    "keys": ["ctrl+u","ctrl+u"],
    "command": "swap_case"
  },
  // 书签
  {
    "keys": ["ctrl+k","ctrl+n"],
    "command": "next_bookmark"
  },
  {
    "keys": ["ctrl+k","ctrl+p"],
    "command": "prev_bookmark"
  },
  {
    "keys": ["ctrl+k","ctrl+k"],
    "command": "toggle_bookmark",
    "args": {
      "toggle_line": true
    }
  },
  {
    "keys": ["ctrl+k","ctrl+c"],
    "command": "clear_bookmarks"
  },
  // 行操作
  {
    "keys": ["ctrl+j"],
    "command": "join_lines"
  },
  {
    "keys": ["alt+up"],
    "command": "swap_line_up"
  },
  {
    "keys": ["alt+down"],
    "command": "swap_line_down"
  },
    {
    "key": "alt+d",
    "command": "duplicate_line"
  },
  {
    "keys": ["alt+shift+up"],
    "command": "duplicate_line"
  },
  {
    "keys": ["alt+shift+down"],
    "command": "duplicate_line"
  },
  // 插入光标
  {
    "keys": ["ctrl+shift+up"],
    "command": "select_lines",
    "args": {
      "forward": false
    }
  },
  {
    "keys": ["ctrl+shift+down"],
    "command": "select_lines",
    "args": {
      "forward": true
    }
  },
  // 选择
  {
    "keys": ["alt+shift+o"],
    "command": "expand_selection",
    "args": {
      "to": "scope"
    }
  },
  {
    "keys": ["alt+shift+a"],
    "command": "expand_selection",
    "args": {
      "to": "smart"
    }
  },
  {
    "keys": ["alt+shift+9"],
    "command": "expand_selection",
    "args": {
      "to": "brackets"
    }
  },
  {
    "keys": ["alt+shift+t"],
    "command": "expand_selection",
    "args": {
      "to": "tag"
    },
    "context": [{"key": "selector","operator": "equal","operand": "(text.html, text.xml) - source","match_all": true}]
  },
  // 编辑器 (聚焦、分组、布局)
  {
    "keys": ["alt+9"],
    "command": "select_by_index",
    "args": {
      "index": 8
    }
  },
  {
    "keys": ["alt+0"],
    "command": "select_last_tab"
  },
  {
    "keys": ["ctrl+\\"],
    "command": "new_pane"
  },
  {
    "keys": ["ctrl+shift+\\"],
    "command": "close_pane"
  },
  {
    "keys": ["alt+shift+pageup"],
    "command": "move_to_neighboring_group",
    "args": {
      "forward": false
    }
  },
  {
    "keys": ["alt+shift+pagedown"],
    "command": "move_to_neighboring_group"
  },
  // 侧边栏
  {
    "keys": ["ctrl+b"],
    "command": "toggle_side_bar"
  },
  // 自动换行
  {
    "keys": ["alt+z"],
    "command": "toggle_setting",
    "args": {
      "setting": "word_wrap"
    }
  }
]

配置

配置入口:菜单 Preferences > Settings

{
    // 显示折叠按钮
    "fade_fold_buttons": false,
    // 索引文件
    "index_files": true,
    // 显示空白符 (空格,制表符)
    "draw_white_space": ["all","selection_none"],
    // 显示 non-ascii 空白符 (zero-width space,non-breaking space)
    "draw_unicode_white_space": "all",
    // 自动移除行尾空白符
    "trim_trailing_white_space_on_save": "all",
    // 支持反向缩进
    "shift_tab_unindent": true,
    // 文件末尾自动添加换行符
    "ensure_newline_at_eof_on_save": true,
    // 高亮当前行
    "highlight_line": true,
    // 不显示左右滚动按钮
    "hide_tab_scrolling_buttons": true,
    // 不显示创建 Tab 按钮
    "hide_new_tab_button": true,
    // 显示文件相对路径
    "show_rel_path": true,
    // 光标样式
    "caret_style": "solid",
    "caret_extra_top": 0,
    "caret_extra_bottom": 0,
    "caret_extra_width": 1,
    // 主题样式
    "font_size": 11,
    "color_scheme": "Mariana.sublime-color-scheme",
    "theme": "Adaptive.sublime-theme",
    "themed_title_bar": true,
}

其它

  • 开启命令记录,在 Console 中输入 sublime.log_commands(True)
  • Key Bindings
[
// 命名为 snake_case 风格
{
"keys": ["ctrl+u","ctrl+s"],
"command": "convert_ident_case",
"args": {
"case": "lower",
"separator": "_"
}
},
// 命名为 kebab-case 风格
{
"keys": ["ctrl+u","ctrl+k"],
"command": "convert_ident_case",
"args": {
"case": "lower",
"separator": "-"
}
},
// 命名为 camelCase 风格
{
"keys": ["ctrl+u","ctrl+c"],
"command": "convert_ident_case",
"args": {
"case": "title",
"first_case": "lower"
}
},
// 命名为 PascalCase 风格
{
"keys": ["ctrl+u","ctrl+p"],
"command": "convert_ident_case",
"args": {
"case": "title"
}
},
// 切换命名风格
{
"keys": ["ctrl+u","ctrl+u"],
"command": "swap_case"
},
// 上一个书签
{
"keys": ["ctrl+k","ctrl+p"],
"command": "prev_bookmark"
},
// 下一个书签
{
"keys": ["ctrl+k","ctrl+n"],
"command": "next_bookmark"
},
// 添加/取消书签
{
"keys": ["ctrl+k","ctrl+k"],
"command": "toggle_bookmark",
"args": {
"toggle_line": true
}
},
// 清除所有书签
{
"keys": ["ctrl+k","ctrl+c"],
"command": "clear_bookmarks"
},
// 合并选择内容为一行
{
"keys": ["ctrl+j"],
"command": "join_lines"
},
// 选择内容/光标所在行,上移
{
"keys": ["alt+up"],
"command": "swap_line_up"
},
// 选择内容/光标所在行,下移
{
"keys": ["alt+down"],
"command": "swap_line_down"
},
// 选择内容/光标所在行,再制 (复制并粘贴)
{
"keys": ["alt+shift+up"],
"command": "duplicate_line"
},
{
"keys": ["alt+shift+down"],
"command": "duplicate_line"
},
{
"key": "alt+d",
"command": "duplicate_line"
},
// 列模式:光标所在位置‘向上’插入光标
{
"keys": ["ctrl+shift+up"],
"command": "select_lines",
"args": {
"forward": false
}
},
// 列模式:光标所在位置‘向下’插入光标
{
"keys": ["ctrl+shift+down"],
"command": "select_lines",
"args": {
"forward": true
}
},
// 扩展选择,向外
{
"keys": ["alt+shift+o"],
"command": "expand_selection",
"args": {
"to": "scope"
}
},
// 扩展选择,智能作用域
{
"keys": ["alt+shift+a"],
"command": "expand_selection",
"args": {
"to": "smart"
}
},
// 扩展选择,括号内
{
"keys": ["alt+shift+9"],
"command": "expand_selection",
"args": {
"to": "brackets"
}
},
// 扩展选择,标签内
{
"keys": ["alt+shift+t"],
"command": "expand_selection",
"args": {
"to": "tag"
},
"context": [{"key": "selector","operator": "equal","operand": "(text.html, text.xml) - source","match_all": true}]
},
// 聚焦第9个标签 (与 VS Code 一致)
{
"keys": ["alt+9"],
"command": "select_by_index",
"args": {
"index": 8
}
},
// 聚焦最后一个标签
{
"keys": ["alt+0"],
"command": "select_last_tab"
},
// 编辑器分组 (新建)
{
"keys": ["ctrl+\\"],
"command": "new_pane"
},
// 编辑器分组 (关闭)
{
"keys": ["ctrl+shift+\\"],
"command": "close_pane"
},
// ‘编辑器’移动 (前一组)
{
"keys": ["alt+shift+pageup"],
"command": "move_to_neighboring_group",
"args": {
"forward": false
}
},
// ‘编辑器’移动 (后一组)
{
"keys": ["alt+shift+pagedown"],
"command": "move_to_neighboring_group"
},
// 切换侧边栏
{
"keys": ["ctrl+b"],
"command": "toggle_side_bar"
},
// 切换自动换行
{
"keys": ["alt+z"],
"command": "toggle_setting",
"args": {
"setting": "word_wrap"
}
}
]
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"Indent XML",
"JsPrettier",
"Package Control",
"Pretty JSON",
"Pretty YAML",
"SideBarEnhancements",
"Sync Settings",
"Vue Syntax Highlight",
],
"http_proxy": "http://localhost:7897",
}
{
// 显示折叠按钮
"fade_fold_buttons": false,
// 索引文件
"index_files": true,
// 显示空白符 (空格,制表符)
"draw_white_space": ["all","selection_none"],
// 显示 non-ascii 空白符 (zero-width space,non-breaking space)
"draw_unicode_white_space": "all",
// 自动移除行尾空白符
"trim_trailing_white_space_on_save": "all",
// 支持反向缩进
"shift_tab_unindent": true,
// 文件末尾自动添加换行符
"ensure_newline_at_eof_on_save": true,
// 高亮当前行
"highlight_line": true,
// 不显示左右滚动按钮
"hide_tab_scrolling_buttons": true,
// 不显示创建 Tab 按钮
"hide_new_tab_button": true,
// 显示文件相对路径
"show_rel_path": true,
// 光标样式
"caret_style": "solid",
"caret_extra_top": 0,
"caret_extra_bottom": 0,
"caret_extra_width": 1,
// 主题样式
"font_size": 11,
"color_scheme": "Mariana.sublime-color-scheme",
"theme": "Adaptive.sublime-theme",
"themed_title_bar": true,
}
{
"indent": 2,
"keep_arrays_single_line": true,
"pretty_on_save": true,
"brace_newline": false,
"as_json": ["Packages/JSON/JSON.sublime-syntax"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment