一款神奇的IDE

Sublime Text 3 原本是一款编辑器,可以用来编辑绝大多数的文件格式。后来,随着相关插件的增加与增强,它也逐渐演变成为一种轻便式的 IDE,能够用于处理 REPL(read-evaluate-print-loop)制式的编程语言,如 RPython等,亦可结合操作系统的终端,实现对 C/C++ 程序的编译。

目前我主要使用的脚本语言,RPython,网页开发语言 htmlJavaScriptcss,以及系统开发语言 C++,均可一站式地在 Sublime Text 中进行编辑、编译、执行操作等。因此,我对 Sublime的使用粘度较高。与此同时,Sublime 让我最为满意的一点,是允许用户通过偏好设置来实现个人定制化的快捷键操作。通过适当的配置个人偏好,可以极大的提升我的编程效率。

这里,我通过分享个人常用的一些插件、系统偏好设置、快捷键设置,与诸位看客一同来见证 Sublime 的神奇。

常用软件包

以下是我常用的一些增强软件包:

  • R-Box
  • R-snippets
  • R_comments
  • sendCode:通过 Sublime 向系统的终端发送命令
  • Sublime REPL:执行操作,实现 REPL

    • 如果需要再 REPL 屏幕显示命令, 可以这样设置: preference -> Package Settings -> SublimeREPL -> Setting User -> 添加

      { “show_transferred_text”: true }

  • SFTP:连接远程服务器,实现在本地 IDE 编辑服务器上面的文件
  • Material Theme:一款漂亮的主题
  • Material Theme AppBar
  • SideBarEnhancements:增强版的边栏,实现显示项目文件、文件类型图标、文件基本操作等
  • MarkdownLivePreview: alt+m
  • Markdown Extended
  • 解决中文乱码:GBK Support, ConvertToUTF8, Codecs33
  • AutoPEP8:python 规范化
  • SublimeCodeIntel:实现语法自动高亮
  • Python BreakPoint
  • Markdown 预览: markmon
  • Git + Github:Git, GithubTools, 实现在 Sublime 显示修改痕迹、直接上传修改等功能
  • Jedi python autocomplete:非常好用的自动补全代码
  • StatusBarTime: 在状态栏显示系统时间
  • GitGutter
  • Auto-save: 通过设置 keybinds:{ “keys”: [“ctrl+shift+s”], “command”: “auto_save” }
  • C++ Completes
  • DocBlockr_Python:Python 格式的注释
  • DocBlockr_with_update_capability
  • PlainTasks:搭建任务列表,异常的温馨好用
  • Plain Notes
  • Alignment: ctrl+altt+a 实现对齐: 在 setting-user 里面添加
  • Terminal: 在文件路径 ctrl + shift + T 打开终端
  • 输入法:https://github.com/lyfeyaj/sublime-text-imfix

偏好设置

修改路径为 Preferences/setting

{
"always_show_minimap_viewport": true,
"auto_complete_commit_on_tab": true,
"auto_find_in_selection": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"default_encoding": "UTF-8",
"draw_minimap_border": false,
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"fold_buttons": true,
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
"font_size": 9,
"format_on_save": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Auto Fold",
"Vintage"
],
"indent_guide_options":
[
"draw_normal",
"draw_active"
],
"line_numbers": true,
"line_padding_bottom": 3,
"line_padding_top": 3,
"match_selection": true,
"mdpopups.sublime_user_lang_map": null,
"mdpopups.use_sublime_highlighter": null,
"overlay_scroll_bars": "enabled",
"reveal_in_side_bar": true,
"rulers":
[
80,
100
],
"save_on_focus_lost": true,
"show_encoding": true,
"show_sidebar_on_activated": true,
"spell_check": false,
"tab_size": 4,
"theme": "Material-Theme.sublime-theme",
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": false,
"update_check": false,
"word_separators": "./\\()\"':,.;<>~!@#$%^&*|+=[]{}`~?",
"word_wrap": true
}

快捷键设置

[
  { "keys": ["enter"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
  [
// { "key": "following_text", "operator": "regex_contains", "operand": "^[)\\]\\>\\'\\\"]", "match_all": true },
  // { "key": "following_text", "operator": "regex_contains", "operand": "^[)\\>\\'\\\"]", "match_all": true },
  { "key": "following_text", "operator": "regex_contains", "operand": "^[\\>\\']", "match_all": true },
  ]
  },

  { "keys": ["control+m"], "command": "insert_snippet", "args": {"contents": " %>% \n"}
  },

// { "keys": ["alt+m"], "command": "insert_snippet", "args": {"contents": " %>% "}
// },

  { "keys": ["control+,"], "command": "insert_snippet", "args": {"contents": " := "}
  },

  { "keys": ["alt+-"], "command": "insert_snippet", "args": {"contents": " <- "}
  },

  { "keys": ["control+."], "command": "insert_snippet", "args": {"contents": " <- "}
  },

  {"keys":["alt+b"],
  "caption": "SublimeREPL: Python - PDB current file",
  "command": "run_existing_window_command", "args":
  {
  "id": "repl_python_pdb",
  "file": "config/Python/Main.sublime-menu"
  }},

  {"keys":["alt+p"],
  "caption": "SublimeREPL: Python - RUN current file",
  "command": "run_existing_window_command", "args":
  {
  "id": "repl_python_run",
  "file": "config/Python/Main.sublime-menu"
  }},

  { "keys": ["ctrl+shift+r"], "command": "reveal_in_side_bar"},

// 设置 Sublime REPL 用 F4 打开 R
  { "keys": ["f4"],
  "caption": "SublimeREPL: R",
  "command":"repl_open","args":
  {
  "type": "subprocess",
  "external_id": "r",
  "additional_scopes": ["tex.latex.knitr"],
  "encoding": {
  "windows": "$win_cmd_encoding",
  "linux": "utf8",
  "osx": "utf8"
  },
  "soft_quit": "\nquit(save=\"no\")\n",
  "cmd": {"linux": ["R", "--interactive", "--no-readline"],
  "osx": ["R", "--interactive", "--no-readline"],
  "windows": ["Rterm.exe", "--ess", "--encoding=$win_cmd_encoding"]},
  "cwd": "$file_path",
  "extend_env": {"osx": {"PATH": "{PATH}:/usr/local/bin"},
  "linux": {"PATH": "{PATH}:/usr/local/bin"},
  "windows": {}},
  "cmd_postfix": "\n",
  "suppress_echo": {"osx": true,
  "linux": true,
  "windows": false},
  "syntax": "Packages/R/R Console.tmLanguage"
  }
  },

// 设置 Sublime REPL 用 F5 打开 Rssh
  { "keys": ["f5"],
  "caption": "SublimeREPL: Rssh",
  "command":"repl_open","args":
  {
  "type": "subprocess",
  "external_id": "r",
  "additional_scopes": ["tex.latex.knitr"],
  "encoding": {
  "windows": "$win_cmd_encoding",
  "linux": "utf8",
  "osx": "utf8"
  },
  "soft_quit": "\nquit(save=\"no\")\n",
  "cmd": {"linux": ["ssh","fl@192.168.1.135","-p22","R","--interactive", "--no-readline"],
  "osx": ["ssh","fl@gczhang.imwork.net", "-p58873","R","--interactive", "--no-readline"]},
  "cwd": "$file_path",
  "extend_env": {"osx": {"PATH": "{PATH}:/usr/local/bin"},
  "linux": {"PATH": "{PATH}:/usr/local/bin"},
  "windows": {}},
  "cmd_postfix": "\n",
  "suppress_echo": {"osx": true,
  "linux": true,
  "windows": false},
  "syntax": "Packages/R/R Console.tmLanguage"
  }
  },

// 设置 Sublime REPL 用 F6 打开 Rssh
  { "keys": ["f6"],
  "caption": "SublimeREPL: Rssh",
  "command":"repl_open","args":
  {
  "type": "subprocess",
  "external_id": "r",
  "additional_scopes": ["tex.latex.knitr"],
  "encoding": {
  "windows": "$win_cmd_encoding",
  "linux": "utf8",
  "osx": "utf8"
  },
  "soft_quit": "\nquit(save=\"no\")\n",
  "cmd": {"linux": ["ssh","fl@192.168.1.166","-p22","R","--interactive", "--no-readline"],
  "osx": ["ssh","fl@gczhang.imwork.net", "-p58873","R","--interactive", "--no-readline"]},
  "cwd": "$file_path",
  "extend_env": {"osx": {"PATH": "{PATH}:/usr/local/bin"},
  "linux": {"PATH": "{PATH}:/usr/local/bin"},
  "windows": {}},
  "cmd_postfix": "\n",
  "suppress_echo": {"osx": true,
  "linux": true,
  "windows": false},
  "syntax": "Packages/R/R Console.tmLanguage"
  }
  },

// 设置 Sublime REPL 用 F1 打开 python
  { "keys": ["f1"],
  "caption": "SublimeREPL: Python",
  "command":"repl_open","args":
  {
  "type": "subprocess",
  "encoding": "utf8",
  //"cmd": ["python", "-i", "-u"],
  "cmd": ["/home/william/anaconda2/bin/python", "-i", "-u"],
  "cwd": "$file_path",
  "syntax": "Packages/Python/Python.tmLanguage",
  "external_id": "python",
  "extend_env": {"PYTHONIOENCODING": "utf-8"}
  }
  },
// 设置 Sublime REPL 用 F2 运行 python
  // { "keys": ["f2"],
  // "caption": "SublimeREPL: Python - RUN current file",
  // "command":"repl_open","args":
  // {
  // "type": "subprocess",
  // "encoding": "utf8",
  // "cmd": ["/home/william/anaconda2/bin/python", "-u", "$file_basename"],
  // "cwd": "$file_path",
  // "syntax": "Packages/Python/Python.tmLanguage",
  // "external_id": "python",
  // "extend_env": {"PYTHONIOENCODING": "utf-8"}
  // }
  // },

// 设置 Sublime REPL 用 F2 运行 python_ssh
  { "keys": ["f2"],
  "caption": "SublimeREPL: PySSH",
  "command":"repl_open","args":
  {
  "type": "subprocess",
  "encoding": "utf8",
  "cmd": {"linux": ["ssh","fl@192.168.1.135","-p22","python", "-i", "-u"]},
  "cwd": "$file_path",
  "syntax": "Packages/Python/Python.tmLanguage",
  "suppress_echo": false,
  "external_id": "python",
  "extend_env": {"PYTHONIOENCODING": "utf-8"},
  "cmd_postfix": "\n",
  "suppress_echo": {"osx": true,
  "linux": true,
  "windows": false}
  }
  },

// 设置 Sublime REPL 用 F3 运行 python_ssh
  { "keys": ["f3"],
  "caption": "SublimeREPL: PySSH",
  "command":"repl_open","args":
  {
  "type": "subprocess",
  "encoding": "utf8",
  "cmd": {"linux": ["ssh","fl@192.168.1.166","-p22","python", "-i", "-u"]},
  "cwd": "$file_path",
  "syntax": "Packages/Python/Python.tmLanguage",
  "suppress_echo": false,
  "external_id": "python",
  "extend_env": {"PYTHONIOENCODING": "utf-8"},
  "cmd_postfix": "\n",
  "suppress_echo": {"osx": true,
  "linux": true,
  "windows": false}
  }
  },

  { "keys": ["ctrl+shift+s"], "command": "auto_save" },
  {"keys": ["ctrl+o"], "command": "toggle_side_bar"},

  // { "keys": ["ctrl+b"], "command": "sftp_browse_server" },
  { "keys": ["ctrl+b"], "command": "sftp_last_server" },

  { "keys": ["ctrl+d"], "command": "find_under_expand" },
]

注册码

网站

由于 Sublime Text 3 并非是一款免费的编辑器,目前的收费标准是 $80。与此同时,也并非强制用户必须购买才能使用,而是以试用的形式,经过一段时间后,会时不时的弹出提醒购买的消息框。对此,这里提供了一个注册码网站,可以使用其提供的注册码来获取使用权限。具体网址为

Sublime Text 3 3143 注册码

源码

有部分童鞋反馈说上面的网站无法打开,似乎需要爬楼梯才能出去。这里我就勉为其难地做一回纯粹的代码搬运工,把源码放在这里了。各位请自取。

—– BEGIN LICENSE —–
TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB
—— END LICENSE ——