前端神器之Sublime Text2/3简单明了使用总结_html/css_WEB-ITnose
我总结如下:
第一:也是最重要的,它占内存很小(就如同notepad++那般迅速打开,所以那款其实也不错~)。一般IDE比如WebStorm(它也是一款神器来着),Aptana(也比较常用),还有前后结合的Zend Studio 等都略显臃肿,打开太慢,耗内存太大。
第二:主题丰富,漂亮的界面。各式各样的主题可以满足你的视觉美。
第三:支持的插件丰富多样。很多插件都能让你获得不一样的体验。
第四:支持命令快捷键方式。就如同vim那般有广阔的命令快捷。
好吧,那就来下载安装吧。
Sublime Text2或者3都没关系,3也只是作为2的beta版本,所以还是推荐3吧,支持新版嘛。2和3在使用方法功能上也有差异~
(1)你可以去官网下载对应版本,但可能需要输入序列号什么的。
访问http://www.sublimetext.com/2下载2.x版本。
或从http://www.sublimetext.com/3下载3.x版本。
注册码(仅供个人非商业应用):
----- BEGIN LICENSE ------ Alexander Single User License EA7E-814345 51F47F09 4EAB1285 7827EFF0 8B1207DC A76A6EA3 E1A1CA7A DC1F2703 14,897,784 8EDC1C82 3F2A58B9 1C0C8B24 67686432 281245B3 6233DE5C ADC5C2F9 61FB8A04 171B63EF 86BA423F 6AC884FD 3273A7AA 5F50A6DB CE7859AE D62D2B37 AEEDD8C2 078A8A20 70EEA791 84F48C1E 8ABA7DEB 0B3907C0 C9A3523B 0091A045 6F67AED8 ------ END LICENSE ------
----- BEGIN LICENSE -----Andrew Weber Single User License EA7E-855605 813A03DD 5E4AD9E6 6C0EEB94 BC99798F 942194A6 02396E98 E62C9979 4BB979FE 91424C9D A45400BF F6747D88 2FB88078 90F5CC94 1CDC92DC 8457107A F151657B 1D22E383 A997F016 42397640 33F41CFC E1D0AE85 A0BBD039 0E9C8D55 E1B89D5D 5CDB7036 E56DE1C0 EFCC0840 650CD3A6 B98FC99C 8FAC73EE D2B95564 DF450523 ------ END LICENSE ------
(2)一般官网下来的都是英文原版的,可以网上找些中文包放进去就行了。你也可以直接去其他网站下载Sublime Text,一般下下来就可以直接使用了。。
先来基本配置
基本配置可以在窗口布局的那几个选项自己设定,当然也可以在配置文件里边直接开干。
配置文件在:preferences-setting user 或者 setting default
因为user的可以覆盖default的,而且你重装啊什么的也不怕被抹掉,所以推荐你直接写进setting user里边
我是text3 中文版的:
直接在里边写点配置信息就行了,比如:
{ //字体大小 "font_size": 11.0, //字体类型 "font_face": "微软雅黑", // 设置每一行到顶部,以像素为单位的间距,效果相当于行距 "line_padding_top": 2, // 设置每一行到底部,以像素为单位的间距,效果相当于行距 "line_padding_bottom": 2, //检查更新 "update_check":false, //长单词换行形式 "word_wrap":"auto", // html和xml下突出显示光标所在标签的两端,影响HTML、XML、CSS等 "match_tags": true, // 是否显示代码折叠按钮 "fold_buttons": true, // 代码提示 "auto_complete": true, // 默认编码格式 "default_encoding": "UTF-8", // 左边边栏文件夹动画 "tree_animation_enabled": true, //删除你想要忽略的插件 "ignored_packages": [ "Vintage", "YUI Compressor" ] }
下边总结了一些更多的配置信息,需要的可打开看看~
1 // While you can edit this file, it's best to put your changes in 2 3 // "User/Preferences.sublime-settings", which overrides the settings in here. 4 // 5 // Settings may also be placed in file type specific options files, for 6 // example, in Packages/Python/Python.sublime-settings for python files. 7 { 8 // Sets the colors used within the text area 9 //主题文件 10 "color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme", 11 12 // Note that the font_face and font_size are overriden in the platform 13 // specific settings file, for example, "Preferences (Linux).sublime-settings". 14 // Because of this, setting them here will have no effect: you must set them 15 // in your User File Preferences. 16 //字体样式、大小 17 "font_face": "", 18 "font_size": 10, 19 20 // Valid options are "no_bold", "no_italic", "no_antialias", "gray_antialias", 21 // "subpixel_antialias", "no_round" (OS X only) and "directwrite" (Windows only) 22 // 字体选项:no_bold不显示粗体字,no_italic不显示斜体字,no_antialias和no_antialias关闭反锯齿 23 // subpixel_antialias和no_round是OS X系统独有的 24 // directwrite是Windows系统独有的 25 "font_options": [], 26 27 // Characters that are considered to separate words 28 // 在文字上双击会全选当前的内容,如果里面出现以下字符,就会被截断 29 "word_separators": "./\\()\"'-:,.;~!@#$%^&*|+=[]{}`~?", 30 31 // Set to false to prevent line numbers being drawn in the gutter 32 // 是否显示行号 33 "line_numbers": true, 34 35 // Set to false to hide the gutter altogether 36 // 是否显示行号边栏 37 "gutter": true, 38 39 // Spacing between the gutter and the text 40 // 行号边栏和文字的间距 41 "margin": 4, 42 43 // Fold buttons are the triangles shown in the gutter to fold regions of text 44 // 是否显示代码折叠按钮 45 "fold_buttons": true, 46 47 // Hides the fold buttons unless the mouse is over the gutter 48 // 不管鼠标在不在行号边栏,代码折叠按钮一直显示 49 "fade_fold_buttons": true, 50 51 // Columns in which to display vertical rulers 52 //列显示垂直标尺,在中括号里填入数字,宽度按字符计算 53 "rulers": [], 54 55 // Set to true to turn spell checking on by default 56 // 是否打开拼写检查 57 "spell_check": false, 58 59 // The number of spaces a tab is considered equal to 60 // Tab键制表符宽度 61 "tab_size": 4, 62 63 // Set to true to insert spaces when tab is pressed 64 // 设为true时,缩进和遇到Tab键时使用空格替代 65 "translate_tabs_to_spaces": false, 66 67 // If translate_tabs_to_spaces is true, use_tab_stops will make tab and 68 // backspace insert/delete up to the next tabstop 69 // translate_tabs_to_spaces设置为true,Tab和Backspace的删除/插入作用于制表符宽度 70 // 否则作用于单个空格 71 "use_tab_stops": true, 72 73 // Set to false to disable detection of tabs vs. spaces on load 74 // false时禁止在载入的时候检测制表符和空格 75 "detect_indentation": true, 76 77 // Calculates indentation automatically when pressing enter 78 // 按回车时,自动与制表位对齐 79 "auto_indent": true, 80 81 // Makes auto indent a little smarter, e.g., by indenting the next line 82 // after an if statement in C. Requires auto_indent to be enabled. 83 //针对C语言的 84 "smart_indent": true, 85 86 // Adds whitespace up to the first open bracket when indenting. Requires 87 // auto_indent to be enabled. 88 // 需要启用auto_indent,第一次打开括号缩进时插入空格?(没测试出来效果…) 89 "indent_to_bracket": false, 90 91 // Trims white space added by auto_indent when moving the caret off the 92 // line. 93 // 显示对齐的白线是否根据回车、tab等操作自动填补 94 "trim_automatic_white_space": true, 95 96 // Disables horizontal scrolling if enabled. 97 // May be set to true, false, or "auto", where it will be disabled for 98 // source code, and otherwise enabled. 99 // 是否自动换行,如果选auto,需要加双引号100 "word_wrap": "auto",101 102 // Set to a value other than 0 to force wrapping at that column rather than the103 // window width104 // 设置窗口内文字区域的宽度105 "wrap_width": 0,106 107 // Set to false to prevent word wrapped lines from being indented to the same108 // level109 // 防止被缩进到同一级的字换行110 "indent_subsequent_lines": true,111 112 // Draws text centered in the window rather than left aligned113 // 如果没有定义过,则文件居中显示(比如新建的文件)114 "draw_centered": false,115 116 // Controls auto pairing of quotes, brackets etc117 // 自动匹配引号,括号等118 "auto_match_enabled": true,119 120 // Word list to use for spell checking121 // 拼写检查的单词列表路径122 "dictionary": "Packages/Language - English/en_US.dic",123 124 // Set to true to draw a border around the visible rectangle on the minimap.125 // The color of the border will be determined by the "minimapBorder" key in126 // the color scheme127 // 代码地图的可视区域部分是否加上边框,边框的颜色可在配色方案上加入minimapBorder键128 "draw_minimap_border": false,129 130 // If enabled, will highlight any line with a caret131 // 突出显示当前光标所在的行132 "highlight_line": false,133 134 // Valid values are "smooth", "phase", "blink", "wide" and "solid".、135 // 设置光标闪动方式136 "caret_style": "smooth",137 138 // Set to false to disable underlining the brackets surrounding the caret139 // 是否特殊显示当前光标所在的括号、代码头尾闭合标记140 "match_brackets": true,141 142 // Set to false if you'd rather only highlight the brackets when the caret is143 // next to one144 // 设为false时,只有光标在括号或头尾闭合标记的两端时,match_brackets才生效145 "match_brackets_content": true,146 147 // Set to false to not highlight square brackets. This only takes effect if148 // match_brackets is true149 // 是否突出显示圆括号,match_brackets为true生效150 "match_brackets_square": true,151 152 // Set to false to not highlight curly brackets. This only takes effect if153 // match_brackets is true154 // 是否突出显示大括号,match_brackets为true生效155 "match_brackets_braces": true,156 157 // Set to false to not highlight angle brackets. This only takes effect if158 // match_brackets is true159 // 是否突出显示尖括号,match_brackets为true生效160 "match_brackets_angle": false,161 162 // Enable visualization of the matching tag in HTML and XML163 // html和xml下突出显示光标所在标签的两端,影响HTML、XML、CSS等164 "match_tags": true,165 166 // Highlights other occurrences of the currently selected text167 // 全文突出显示和当前选中字符相同的字符168 "match_selection": true,169 170 // Additional spacing at the top of each line, in pixels171 // 设置每一行到顶部,以像素为单位的间距,效果相当于行距172 "line_padding_top": 0,173 174 // Additional spacing at the bottom of each line, in pixels175 // 设置每一行到底部,以像素为单位的间距,效果相当于行距176 "line_padding_bottom": 0,177 178 // Set to false to disable scrolling past the end of the buffer.179 // On OS X, this value is overridden in the platform specific settings, so180 // you'll need to place this line in your user settings to override it.181 // 设置为false时,滚动到文本的最下方时,没有缓冲区182 "scroll_past_end": true,183 184 // This controls what happens when pressing up or down when on the first185 // or last line.186 // On OS X, this value is overridden in the platform specific settings, so187 // you'll need to place this line in your user settings to override it.188 // 控制向上或向下到第一行或最后一行时发生什么(没明白也没试出来)189 "move_to_limit_on_up_down": false,190 191 // Set to "none" to turn off drawing white space, "selection" to draw only the192 // white space within the selection, and "all" to draw all white space193 // 按space或tab时,实际会产生白色的点(一个空格一个点)或白色的横线(tab_size设置的制表符的宽度),选中状态下才能看到194 // 设置为none时,什么情况下都不显示这些点和线195 // 设置为selection时,只显示选中状态下的点和线196 // 设置为all时,则一直显示197 "draw_white_space": "selection",198 199 // Set to false to turn off the indentation guides.200 // The color and width of the indent guides may be customized by editing201 // the corresponding .tmTheme file, and specifying the colors "guide",202 // "activeGuide" and "stackGuide"203 // 制表位的对齐白线是否显示,颜色可在主题文件里设置(guide,activeGuide,stackGuide)204 "draw_indent_guides": true,205 206 // Controls how the indent guides are drawn, valid options are207 // "draw_normal" and "draw_active". draw_active will draw the indent208 // guides containing the caret in a different color.209 // 制表位的对齐白线,draw_normal为一直显示,draw_active为只显示当前光标所在的代码控制域210 "indent_guide_options": ["draw_normal"],211 212 // Set to true to removing trailing white space on save213 // 为true时,保存文件时会删除每行结束后多余的空格214 "trim_trailing_white_space_on_save": false,215 216 // Set to true to ensure the last line of the file ends in a newline217 // character when saving218 // 为true时,保存文件时光标会在文件的最后向下换一行219 "ensure_newline_at_eof_on_save": false,220 221 // Set to true to automatically save files when switching to a different file222 // or application223 // 切换到其它文件标签或点击其它非本软件区域,文件自动保存224 "save_on_focus_lost": false,225 226 // The encoding to use when the encoding can't be determined automatically.227 // ASCII, UTF-8 and UTF-16 encodings will be automatically detected.228 // 编码时不能自动检测编码时,将自动检测ASCII, UTF-8 和 UTF-16229 "fallback_encoding": "Western (Windows 1252)",230 231 // Encoding used when saving new files, and files opened with an undefined232 // encoding (e.g., plain ascii files). If a file is opened with a specific233 // encoding (either detected or given explicitly), this setting will be234 // ignored, and the file will be saved with the encoding it was opened235 // with.236 // 默认编码格式237 "default_encoding": "UTF-8",238 239 // Files containing null bytes are opened as hexadecimal by default240 // 包含空字节的文件被打开默认为十六进制241 "enable_hexadecimal_encoding": true,242 243 // Determines what character(s) are used to terminate each line in new files.244 // Valid values are 'system' (whatever the OS uses), 'windows' (CRLF) and245 // 'unix' (LF only).246 // 每一行结束的时候用什么字符做终止符247 "default_line_ending": "system",248 249 // When enabled, pressing tab will insert the best matching completion.250 // When disabled, tab will only trigger snippets or insert a tab.251 // Shift+tab can be used to insert an explicit tab when tab_completion is252 // enabled.253 // 设置为enabled时,在一个字符串间按Tab将插入一个制表符254 // 设置为true时,按Tab会根据前后环境进行代码自动匹配填补255 "tab_completion": true,256 257 // Enable auto complete to be triggered automatically when typing.258 // 代码提示259 "auto_complete": true,260 261 // The maximum file size where auto complete will be automatically triggered.262 // 代码提示的大小限制263 "auto_complete_size_limit": 4194304,264 265 // The delay, in ms, before the auto complete window is shown after typing266 // 代码提示延迟显示267 "auto_complete_delay": 50,268 269 // Controls what scopes auto complete will be triggered in270 // 代码提示的控制范围271 "auto_complete_selector": "source - comment",272 273 // Additional situations to trigger auto complete274 // 触发代码提示的其他情况275 "auto_complete_triggers": [ {"selector": "text.html", "characters": "
接下来就是它的最强项,插件的安装:
插件的安装有两个办法:(1)直接把插件放到它的安装路径对应文件包packages里面去,不知道在哪的可以直接打开 preferences->Browse packages
放进去之后软件会自动检测
(2)使用命令方式直接让软件自己下载安装。(使用package control组件)
按下Ctrl+Shift+P调出命令面板,输入install, 调出 Install Package 选项并回车,然后在列表中选中要安装的插件。(这一步你要先安装下面那个package control插件)
常用插件:
(1)package control
通过快捷键 ctrl+` 或者 View > Show Console 菜单打开控制台
然后粘贴对应的版本代码进去,然后回车让它安装~
适用于 Sublime Text 3:
import urllib.request,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler()));open(os.path.join(ipp,pf),'wb').write(urllib.request.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())
适用于 Sublime Text 2:
import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp)ifnotos.path.exists(ipp)elseNone;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()));open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read());print('Please restart Sublime Text to finish installation')当然了,有些时候这样你安装不进去的,就只能自个去下载安装包放到package文件里边去了(就是上边我说的那个文件夹)
如果在Preferences → Package Settings 中看到 Package Control 这一项,说明安装成功。这样:
好了接下来我们就可以直接用它来安装插件了~
(2)举个例子吧:比如这个插件 Alignment(代码补齐)
补齐就是补齐~就像这样
你可以去插件库下载:https://github.com/wbond/sublime_alignment
然后把它放到package文件包中。
如果没用过Github的朋友不知道在哪里下载..看这个图~
然后把它解压,把文件夹放进package文件包,然后它就能检测到包啦~体验一下
然后介绍一下命令的方式,键入Ctrl+shift+p 输入install 选择package install 过几秒会弹出另一个框。
然后在输入框中输入你想要的插件关键字就行,然后就选择安装吧~
大致就是这样,简单明了。下面介绍其他常用插件,安装方式同理~
(3)Zen Coding(现已改名为Emmet) 下载:https://github.com/sergeche/emmet-sublime
zen coding 就是通过简单的命令直接生成一大段代码!一个字又快又准~
安装好插件后,使用Ctrl + Alt + Enter 呼出ZenCoding。
我们可以用 div#content>ul>li*3>a[href="javascript:void(0);"]{Links$} 这样短短的一句话,生成下面一段代码:
更多的技巧就自己去学学吧~
(4)ColorPicker(调色盘) 下载:https://github.com/weslly/ColorPicker
在编辑CSS样式的时候,ColorPicker可以让sublime text 内置一个调色盘,调好颜色,点击OK就会在光标处生成十六进制颜色代码。
(5)SublimeTmpl(自定义新建文件) 下载:https://github.com/kairyou/SublimeTmpl
默认已经添加了html、css、js等常见类型的面板,按ctrl+alt+h/ctrl+alt+c/ctrl+alt+j可新建这 3钟类型的文件,快捷键在这里\Packages\SublimeTmpl\Default (Windows).sublime-keymap, 模板文件在这里\Packages\SublimeTmpl\templates,可修改。 比如下边简单的html文件
(6)
BracketHighlighter高亮显示匹配的括号、引号和标签
BracketHighlighter这个插件能在左侧高亮显示匹配的括号、引号和标签,能匹配的[] , () , {} , "" , '' ,
等甚至是自定义的标签,当看到密密麻麻的代码分不清标签之间包容嵌套的关系时,这款插件就能很好地帮你理清楚代码结构,快速定位括号,引号和标签内的范围。
(7)
还有更多插件,可以自行去搜索下载~我没时间了要出去了 T_T...
比如:
其他插件:
Clipboard-history(粘贴板历史记录) 下载:https://github.com/kemayo/sublime-text-2-clipboard-history
CSScomb(CSS属性排序) 下载:https://github.com/csscomb/CSScomb-for-Sublime
Gits(集成 GitHub) 下载:https://github.com/kemayo/sublime-text-git
Hex-to-HSL-Color Hex(颜色模式转HSL颜色模式) 下载:https://github.com/atadams/Hex-to-HSL-Color
HtmlTidy(清理与排版你的HTML代码) 下载:https://github.com/welovewordpress/SublimeHtmlTidy
JsFormat(javascript格式化) 下载:https://github.com/jdc0589/JsFormat
PHPTidy(整理与排版PHP代码) 下载:https://github.com/welovewordpress/SublimePhpTidy
SideBarEnhancements(侧边栏增强) 下载:https://github.com/titoBouzout/SideBarEnhancements
SublimeLinter(代码错误提示) 下载:https://github.com/SublimeLinter/SublimeLinter/tree/sublime-text-3
SFTP(编辑 FTP 或 SFTP 服务器上的文件) 下载:http://wbond.net/sublime_packages/sftp
Tradsim(中文繁字体和简体字转换) 下载:https://github.com/erinata/SublimeTradsim
TrailingSpacer(高亮显示多余的空格和Tab) 下载:https://github.com/SublimeText/TrailingSpaces
YUI Compressor(压缩JS和CSS文件) 下载:https://github.com/kairyou/SublimeYUICompressor
---------先到这里了----------