sublime-text-2使用汇总
坑
- tab 4 位 怎么都调整不好
设置 tab = space4 出错时
其实是sublime字体的问题,可以通过setting - user 设置新的字体即可
{
"font_face": "DejaVu Sans Mono",
"font_size": 12
}
- 绑定快捷键 alt 在ubuntu14.04下,有时会和菜单有冲突
来源: http://www.sublimetext.com/forum/viewtopic.php?f=2&t=8816
比如,设置 alt + h 是移动光标的,但 会触发 “帮助”菜单 (不是一定冲突,在ubuntu 12.04 上就没有出现)
可以在 新建 一个 文件 .gtkrc-2.0
$: vi ~/.gtkrc-2.0
里面输入 gtk-enable-mnemonics = 0
保存后 ,重启 sublime 即可。
save project
如果使用打开文件夹 的方式打开一个项目,那么 打开多个项目时,只有最后一个会记住打开了哪些tab页
这时候可以使用 菜单栏的 project--》save project as, 下次再进入时, 按ctrl+alt+p
即可切换到不同项目,打开过的tab页也会记住
打开 vim(后来直接使用 快捷键移动 代替了)
- 设置默认快捷键:
preferences
-->Key Bindings default
里面,注释或删除下面这几行
{ "keys": ["ctrl+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse":false} },
{ "keys": ["ctrl+shift+i"], "command": "show_panel", "args": {"panel": "incremental_find", "reverse":true} },
把这个["ctrl+i"] 给 vim 用 (也有使用 ["i","i"])
{
"keys": ["ctrl+i"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
}
- 打开 vim ctrl 按钮 参考
- Ctrl+[: Escape 没什么用
- Ctrl+R: Redo 没什么用
- Ctrl+Y: Scroll down one line
- Ctrl+E: Scroll up one line
- Ctrl+F: Page Down
- Ctrl+B: Page Up
插件 汇总:
- Emmet(zend coder的进阶版) 快速编辑 html
- ColorPicker 调颜色
- ColorHighlighter 高亮color (没有用,和vim 也有冲突)
- console.log函数 设置 snippt
- Markdown Preview:配色方案在sublimetext 3 中,使用了markdown-extend插件 ,详见 《st3 使用汇总》
- 打开当前页面 用chrome 浏览器,默认是火狐
- ctags
- Jshint
- Alignment 对齐
- DocBlockr 函数 类的解释。
- SublimeNavigationHistory 回到原来编辑位置 不是很好用
- 打开url链接地址
- twig 高亮
其他
- diff 不好用
- inputHelper 输入中文
- jquery
- sublimeblockcursor 方便vim
- sublimerge Pro 不好用 (不过现在sublimetext 3 在使用)
详细:
SideBarEnhancements
对应侧边兰增强 sublime text2 没有用
emmet(zend coder的进阶版)
资料:
http://html5.9tech.cn/news/2013/1010/33090.html
http://www.douban.com/note/299431625/?qq-pf-to=
- 修改配置
可以通过 配置 emmet 文件夹中的 snippets.json 来添加新缩写或更新现有缩写
padding, margin height 后面+ px
"link:css": "<link rel=\"stylesheet\" type=\"text/css\" href=\"${1:style}.css\" />",
"script:src": "<script type=\"text/javascript\" src=\"\">",
"script": "<script !src=\"\" type=\"text/javascript\">",
"style": "<style type=\"text/css\">",
"a": "<a href=\"javascript:;\">",
// 把原来的
"doc": "html>(head>meta[charset=${charset}]+title{${1:Document}})+body",
// 删除,改为
"doc": "html>(head>meta[http-equiv=\"Content-Type\" content=\"text/html;charset=${charset}\"]+title{${1:Document}})+body",
- 常用的缩写
html:5
和!
是同一个 效果
http://blog.csdn.net/lmmilove/article/details/9181323
ul>li.item$@-*5
如下效果:
<ul>
<li class="item5"></li>
<li class="item4"></li>
<li class="item3"></li>
<li class="item2"></li>
<li class="item1"></li>
</ul>
ul>li.item$@3*5
如下效果:
<ul>
<li class="item3"></li>
<li class="item4"></li>
<li class="item5"></li>
<li class="item6"></li>
<li class="item7"></li>
</ul>
厉害的功能:
选择文本,再按shift+ctrl+g
nav>ul.nav-ul>li.nav-li*>a[href=javascript:;]
如下
<nav>
<ul class="nav-ul">
<li class="nav-li"><a href="javascript:;">首页</a></li>
<li class="nav-li"><a href="javascript:;">公司简介</a></li>
<li class="nav-li"><a href="javascript:;">公司动态</a></li>
<li class="nav-li"><a href="javascript:;">关于我们</a></li>
<li class="nav-li"><a href="javascript:;">联系我们</a></li>
</ul>
</nav>
* Unordered item 1
* Unordered item 2
* Unordered item 3
可以用 |t 来过滤
ul>li[title=$#].ul-li$*>{$#}|t
ColorPicker
可以调颜色
https://github.com/weslly/ColorPicker
可以 通过 ctrl+shift +p
, 再输入colorPicker
启用。
或者 设置快捷键
{ "keys": ["alt+c"], "command": "color_pick" }
ColorHighlighter
https://github.com/Monnoroch/ColorHighlighter ubuntu下安装无效 ,官网提供的 安装qt 建议因为该包太大,没有考虑。
console.log snippet
找到jQuery 那个插件包 ,看到有很多 *.sublime-snippet 后缀名的文件,这个就是函数快捷键定义的位置,创建一个文件名为:
console.sublime-snippet
里面输入:
<snippet>
<content><![CDATA[console.log('${1:info}');$0]]></content>
<tabTrigger>console</tabTrigger>
<description>console.log()</description>
</snippet>
保存后,看下是否有效。
Markdown Preview
http://www.jianshu.com/p/378338f10263
主题: https://www.bram.us/2013/02/08/sublime-text-markdown-syntax-highlighting/
主题 配色代码:
<dict>
<key>name</key>
<string>Markdown: Linebreak</string>
<key>scope</key>
<string>text.html.markdown meta.dummy.line-break</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#A57706</string>
<key>foreground</key>
<string>#E0EDDD</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown: Raw</string>
<key>scope</key>
<string>text.html.markdown markup.raw.inline</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#269186</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown: Punctuation for Inline Block</string>
<key>scope</key>
<string>punctuation.definition.raw.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#269186</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Heading</string> // 标题
<key>scope</key>
<string>markup.heading</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#cb4b16</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Italic</string> // 斜体
<key>scope</key>
<string>markup.italic</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#839496</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Bold</string> // 粗体
<key>scope</key>
<string>markup.bold</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#586e75</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markdown: Punctuation for Bold, Italic</string>
<key>scope</key>
<string>punctuation.definition.bold.markdown, punctuation.definition.italic.markdown</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#586e75</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Underline</string> // 链接
<key>scope</key>
<string>markup.underline</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>underline</string>
<key>foreground</key>
<string>#839496</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Quote</string> // 引用
<key>scope</key>
<string>markup.quote</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#268bd2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Separator</string> // 分割线
<key>scope</key>
<string>meta.separator</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#eee8d5</string>
<key>fontStyle</key>
<string>bold</string>
<key>foreground</key>
<string>#268bd2</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: List</string> // 列表
<key>scope</key>
<string>markup.list</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#aebb9c</string>
</dict>
</dict>
open in Browser: use chrome
http://stackoverflow.com/questions/8023879/sublime-text-2-keyboard-shortcut-to-open-file-in-specified-browser-e-g-chrome
我采用的是 build方式。
but you can add a new "Build System" under Tools -> Build System -> New Build System...
重命名为 Chrome.sublime-build 黏贴下面的内容
{ "cmd": ["google-chrome", "$file"] }
然后重启sublime,仍然 tools -> Build System -> chrome 跑一下,然后下次 就用 ctrl +b 或者 f7 调用
ctags:
用于找到定义的函数
http://jingyan.baidu.com/article/63acb44afb532561fcc17ef4.html
这上面说的比较详细,主要是安装完了 ubuntu终端 下面还要跑一下
sudo apt-get install exuberant-ctags
不过这个ctags的文档里面都有说的。
快捷键需要该下 ,我只保留了 找到定义函数文件的 一个commond,其他都注释了
{
"command": "navigate_to_definition",
"keys": ["ctrl+shift+\\"]
}
就是指快捷键 : ctrl+shift+\
Alignment
对齐 ctrl + alt + A
DocBlockr
用于 函数 类的解释。
SublimeNavigationHistory
不是很好用
回到原来编辑位置 结合 vim模式 的光标
安装下面的插件
$:~/.config/sublime-text-2/Packages$ git clone https://github.com/timjrobinson/SublimeNavigationHistory.git
把里面的快捷键换为:
{ "keys": ["ctrl+minus"], "command": "navigation_history_back"},
{ "keys": ["ctrl+="], "command": "navigation_history_forward"}
ClickableUrls
打开页面中的url (要以 http开头)
https://github.com/leonid-shevtsov/ClickableUrls_SublimeText
{ "keys": ["alt+u"], "command": "open_url" }
sublime Preferences->settings-user
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"font_size": 17,
"highlight_line": true,
"ignored_packages":
[
// "SublimeBlockCursor",
// "Vintage"
],
"tab_size": 4,
"translate_tabs_to_spaces": true,
"vintage_ctrl_keys": true,
"vintage_start_in_command_mode": true,
// 词的分符隔定义,加入中文符号
"word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?,。:;‘’“”、?!¥…()—《》「」『』【】",
// 是否自动换行,值为true,禁用水平滚动;值为false,水平滚动。
// 值为"auto",需要加双引号,文件是源代码设置为false,否则true。
"detect_indentation": true
}
sublime Preferences->Key Bindings-user
[
{
"keys": [
"ctrl+alt+]"
],
"args": {
"action": "next_edit_point"
},
"command": "run_emmet_action",
"context": [
{
"key": "emmet_action_enabled.next_edit_point"
}
]
},
{
"keys": [
"ctrl+alt+["
],
"args": {
"action": "prev_edit_point"
},
"command": "run_emmet_action",
"context": [
{
"key": "emmet_action_enabled.prev_edit_point"
}
]
},
{ "keys": ["ctrl+minus"], "command": "navigation_history_back"},
{ "keys": ["ctrl+="], "command": "navigation_history_forward"},
{ "keys": ["alt+c"], "command": "color_pick" },
{ "keys": ["alt+u"], "command": "open_url" },
// emmet confilict
{
"keys": [
"ctrl+u"
],
"args": {
"action": "disabled_keymap_actions"
},
"command": "run_emmet_action"
},
// 上下移动 一行
{ "keys": ["ctrl+shift+alt+k"], "command": "swap_line_up" },
{ "keys": ["ctrl+shift+alt+j"], "command": "swap_line_down" },
// 上下左右移动
{ "keys": ["alt+h"], "command": "move", "args": {"by": "characters", "forward": false} },
{ "keys": ["alt+l"], "command": "move", "args": {"by": "characters", "forward": true} },
{ "keys": ["alt+k"], "command": "move", "args": {"by": "lines", "forward": false} },
{ "keys": ["alt+j"], "command": "move", "args": {"by": "lines", "forward": true} },
// 上下左右移动并选择
{ "keys": ["alt+shift+h"], "command": "move", "args": {"by": "characters", "forward": false, "extend": true} },
{ "keys": ["alt+shift+l"], "command": "move", "args": {"by": "characters", "forward": true, "extend": true} },
{ "keys": ["alt+shift+k"], "command": "move", "args": {"by": "lines", "forward": false, "extend": true} },
{ "keys": ["alt+shift+j"], "command": "move", "args": {"by": "lines", "forward": true, "extend": true} },
// 左右移动至上/下一个词
{ "keys": ["alt+m"], "command": "move", "args": {"by": "words", "forward": false} },
{ "keys": ["alt+n"], "command": "move", "args": {"by": "words", "forward": true} },
// 左右移动至上/下一个词并选择
{ "keys": ["shift+alt+m"], "command": "move", "args": {"by": "words", "forward": false, "extend": true} },
{ "keys": ["shift+alt+n"], "command": "move", "args": {"by": "word_ends", "forward": true, "extend": true} },
// 屏幕按行上/下滚动
{ "keys": ["ctrl+alt+k"], "command": "scroll_lines", "args": {"amount": 10.0 } },
{ "keys": ["ctrl+alt+j"], "command": "scroll_lines", "args": {"amount": -10.0 } },
{ "keys": ["alt+i"], "command": "move_to", "args": {"to": "bol", "extend": false} },
{ "keys": ["alt+o"], "command": "move_to", "args": {"to": "eol", "extend": false} },
{ "keys": ["shift+alt+i"], "command": "move_to", "args": {"to": "bol", "extend": true} },
{ "keys": ["shift+alt+o"], "command": "move_to", "args": {"to": "eol", "extend": true} },
{ "keys": ["ctrl+alt+i"], "command": "move_to", "args": {"to": "bof", "extend": false} },
{ "keys": ["ctrl+alt+o"], "command": "move_to", "args": {"to": "eof", "extend": false} },
{ "keys": ["shift+ctrl+alt+i"], "command": "move_to", "args": {"to": "bof", "extend": true} },
{ "keys": ["shift+ctrl+alt+o"], "command": "move_to", "args": {"to": "eof", "extend": true} },
// 格式化
// { "keys": ["ctrl+="], "command": "reindent" },
// 查找相同的词 (现在已经移除)
{ "keys": [""], "command": "find_under",
"args": {"select_text": false}
},
{ "keys": [""], "command": "find_under_prev",
"args": {"select_text": false}
}
]