Emmet 使用说明。
Emmet for Sublime Text
Official Emmet plugin for Sublime Text.
- How to install
- Available actions
- Extensions support
- Overriding keyboard shortcuts
- How to expand abbreviatoins with Tab key in other syntaxes
- Notes about Tab key handler
How to install
Warning: this plugin may not work at all in some OSes since it written in JavaScript and uses PyV8 and Google V8 binaries to run. If you experience problems or editor crashes please fill an issue.
With Package Control:
- Run “Package Control: Install Package” command, find and install
Emmet
plugin. - Restart ST editor (if required)
Manually:
- Clone or download git repo into your packages folder (in ST, find Browse Packages… menu item to open this folder)
- Restart ST editor (if required)
WARNING: When plugin is installed, it will automatically download required PyV8 binary so you have to wait a bit (see Loading PyV8 binary message on status bar). If you experience issues with automatic PyV8 loader, try to install it manually.
Available actions
- Expand Abbreviation – Tab or Ctrl+E
- Interactive “Expand Abbreviation” — Ctrl+Alt+Enter
- Match Tag Pair Outward – ⌃D (Mac) / Ctrl+, (PC)
- Match Tag Pair Inward – ⌃J / Shift+Ctrl+0
- Go to Matching Pair – ⇧⌃T / Ctrl+Alt+J
- Wrap With Abbreviation — ⌃W / Shift+Ctrl+G
- Go to Edit Point — Ctrl+Alt+→ or Ctrl+Alt+←
- Select Item – ⇧⌘. or ⇧⌘, / Shift+Ctrl+. or Shift+Ctrl+,
- Toggle Comment — ⇧⌥/ / Shift+Ctrl+/
- Split/Join Tag — ⇧⌘' / Shift+Ctrl+`
- Remove Tag – ⌘' / Shift+Ctrl+;
- Update Image Size — ⇧⌃I / Ctrl+U
- Evaluate Math Expression — ⇧⌘Y / Shift+Ctrl+Y
- Reflect CSS Value – ⇧⌘R / Shift+Ctrl+R
- Encode/Decode Image to data:URL – ⇧⌃D / Ctrl+'
- Rename Tag – ⇧⌘K / Shift+Ctrl+'
Increment/Decrement Number actions:
- Increment by 1: Ctrl+↑
- Decrement by 1: Ctrl+↓
- Increment by 0.1: Alt+↑
- Decrement by 0.1: Alt+↓
- Increment by 10: ⌥⌘↑ / Shift+Alt+↑
- Decrement by 10: ⌥⌘↓ / Shift+Alt+↓
Extensions support
You can easily extend Emmet with new actions and filters or customize existing ones. In Emmet.sublime-settings
, define extensions_path
setting and Emmet will load all .js
and .json
files in specified folder at startup.
The default value of extensions_path
is ~/emmet
, which points to emmet folder inside your OS user’s home folder.
Also, you can create sections named as extension files (e.g. snippets
, preferences
and syntaxProfiles
) inside user’s Emmet.sublime-settings
file and write your customizations there. See original settings file for examples.
Overriding keyboard shortcuts
Sublime Text is a great text editor with lots of features and actions. Most of these actions are bound to keyboard shortcuts so it’s nearly impossible to provide convenient plugin shortcuts for third-party plugins.
If you’re unhappy with default keymap, you can disable individual keyboard shortcuts with disabled_keymap_actions
preference of Emmet.sublime-settings
file.
Use a comma-separated list of action names which default keyboard shortcuts should be disabled. For example, if you want to release Ctrl+E (“Expand Abbreviation”) and Ctrl+U (“Update Image Size”) shortcuts, your must set the following value:
"disabled_keymap_actions": "expand_abbreviation, update_image_size"
You should refer Default (Your-OS-Name).sublime-keymap
file to get action ids (look for args/action
key).
To disable all default shortcuts, set value to all
:
"disabled_keymap_actions": "all"
Not that if you disabled any action like so and you’re create your own keyboard shortcut, you should not use emmet_action_enabled.ACTION_NAME
context since this is the key that disables action.
How to expand abbreviations with Tab in other syntaxes
Emmet expands abbreviations in limited syntaxes only: HTML, CSS, LESS, SCSS and Stylus. The reason to restrict Tab handler to a limited syntax list is because it breaks native Sublime Text snippets.
If you want to abbreviation with Tab in other syntaxes (for example, JSX, HAML etc.) you have to tweak your keyboard shorcuts settings: add expand_abbreviation_by_tab
command for tab
key for required syntax scope selectors. To get current syntax scope selector, press ⇧⌃P (OSX) or Ctrl+Alt+Shift+P, it will be displayed in editor status bar.
Go to Preferences
> Key Bindings — User
and insert the following JSON snippet with properly configured scope selector instead of SCOPE_SELECTOR
token:
{
"keys": ["tab"],
"command": "expand_abbreviation_by_tab",
// put comma-separated syntax selectors for which
// you want to expandEmmet abbreviations into "operand" key
// instead of SCOPE_SELECTOR.
// Examples: source.js, text.html - source
"context": [
{
"operand": "SCOPE_SELECTOR",
"operator": "equal",
"match_all": true,
"key": "selector"
},
// run only if there's no selected text
{
"match_all": true,
"key": "selection_empty"
},
// don't work if there are active tabstops
{
"operator": "equal",
"operand": false,
"match_all": true,
"key": "has_next_field"
},
// don't work if completion popup is visible and you
// want to insert completion with Tab. If you want to
// expand Emmet with Tab even if popup is visible --
// remove this section
{
"operand": false,
"operator": "equal",
"match_all": true,
"key": "auto_complete_visible"
},
{
"match_all": true,
"key": "is_abbreviation"
}
]
}
Tab key handler
Emmet plugin allows you to expand abbreviations with Tab key, just like regular snippets. On the other hand, due to dynamic nature and extensive syntax, sometimes you may get unexpected results. This section describes how Tab handler works and how you can fine-tune it.
By default, Tab handler works in a limited syntax scopes: HTML, XML, HAML, CSS, SASS/SCSS, LESS and strings in programming languages (like JavaScript, Python, Ruby etc.). It means:
- You have to switch your document to one of the syntaxes listed above to expand abbreviations by Tab key.
- With Ctrl-E shortcut, you can expand abbreviations everywhere, its scope is not limited.
- When you expand abbreviation inside strings of programming languages, the output is generated with special output profile named
line
that generates output as a single line.
To fine-tune Tab key handler, you can use the following settings in user’s Emmet.sublime-settings
file:
disable_tab_abbreviations_for_scopes
— a comma-separated list of syntax scopes where Tab key handler should be disabled. For example, if you want disable handler inside strings of programming languages and HAML syntax, your setting will look like this:
"disable_tab_abbreviations_for_scopes": "text.haml, string"
disabled_single_snippet_for_scopes
— a comma-separated list of syntax scopes where Tab handler should be disabled when expanding a single abbreviation. Currently, ST doesn’t provide API for getting list of native snippets. So, for example, if you try to expand aphp
abbreviation, it will be passed to Emmet which outputs<php></php>
instead of PHP block as defined in native ST snippets. As a workaround, if you’re trying to expand a single abbreviation inside scope defined indisabled_single_snippet_for_scopes
setting Emmet will look for its name inside its own snippets catalog first, insideknown_html_tags
setting second and if it’s not found, it allows ST to handle it and expand native abbreviation, if matched.known_html_tags
— a space-separated list of all known HTML tags used for lookup as described above.
If you’re unhappy with Emmet tab handler behavior, you can disable it: just add "disable_tab_abbreviations": true
into user’s Preferences.sublime-settings
file.
Emmet 使用说明。的更多相关文章
- SublimeText3常用插件及快捷键总结
SublimeText可谓是前端工程师的代码编辑神器,自从用上它以后一直爱不释手,特别是它强大的插件功能,简直要逆天了.网上也有很多关于SublimeText3的各种插件介绍,其插件功能之多,让人眼花 ...
- 超好用的谷歌浏览器、Sublime Text、Phpstorm、油猴插件合集
原文:超好用的谷歌浏览器.Sublime Text.Phpstorm.油猴插件合集 - 『精品软件区』 - 吾爱破解 - LCG - LSG |安卓破解|病毒分析|破解软件|www.52pojie.c ...
- SubLime3 Emmet插件终极教程
当我们在手写HTML.CSS等 页面的时候,这款神级插件是不可多得的神器 1.官方示例:http://docs.emmet.io/cheat-sheet/ 2.第三方示例:http://www.w3c ...
- Atitit.项目修改补丁打包工具 使用说明
Atitit.项目修改补丁打包工具 使用说明 1.1. 打包工具已经在群里面.打包工具.bat1 1.2. 使用方法:放在项目主目录下,执行即可1 1.3. 打包工具的原理以及要打包的项目列表1 1. ...
- emmet,jade,haml, slim,less,sass,coffeescript等的实战优缺点
摘要: 文章背景,来自于群内周五晚上的一次头脑风暴式的思维碰撞交流活动. 随着前端技术的蓬勃发展, 各种新技术随着生产力的需要不断的涌入我们的视野, 那今天探讨的话题是这些新时代的前端兵器谱: 一. ...
- awk使用说明
原文地址:http://www.cnblogs.com/verrion/p/awk_usage.html Awk使用说明 运维必须掌握的三剑客工具:grep(文件内容过滤器),sed(数据流处理器), ...
- emmet 系列(1)基础语法
emmet 系列(1)基础语法 emmet 是一个能显著提升开发html和css开发效率的web开发者工具 emmet基本上目前已知的编辑器都有相应的插件,各个编辑器的emmet插件的下载地址:点我下 ...
- 前端开发必备!Emmet使用手册
介绍 Emmet (前身为 Zen Coding) 是一个能大幅度提高前端开发效率的一个工具: 基本上,大多数的文本编辑器都会允许你存储和重用一些代码块,我们称之为"片段".虽然片 ...
- emmet的使用
http://blog.wpjam.com/m/emmet-grammar/ 使用 Emmet 生成 HTML 的语法详解 开源程序 浏览:21537 2013年05月09日 文章目录[隐藏] 生成 ...
随机推荐
- web前端之HTML的前世今生
一个尖括号 < 一个尖括号能干什么 < ? 你可以编出一顶帽子 <(:-p 或一张笑脸 :-> 或诉说一份爱 <3 或者更直接一些 <!DOC ...
- Python中的join()函数的用法
函数:string.join() Python中有join()和os.path.join()两个函数,具体作用如下: join(): 连接字符串数组.将字符串.元组.列表中的元素以指定的字 ...
- Hibernate的映射文件配置
对象关系的映射是用一个XML文档来说明的.映射文档可以使用工具来生成,如XDoclet,Middlegen和AndroMDA等.下面从一个映射的例子开始讲解映射元素,映射文件的代码如下: <?x ...
- C#返回时间格式转换成 js 字符串
在.net 中,调用 post 或者 get和后台通信时,如果有时间返回信息,后台返回的时间信息一般是这样格式:Thu Jul 9 23:14:53 UTC+0800 2015,那么要在前台显示就会有 ...
- Swift根据日期字符串返回日期是星期几
最近在做的一个IOS项目中需要根据日期得出日期代表的是星期几,日期以字符串的形式获得,于是该方法可以简单描述如下: /* * 根据日期格式字符串返回日期代表星期几 * 参数:dateTime,字符串类 ...
- JAVA 1.9 面向对象之封装
1. 面向对象程序设计的三大基本特征:继承(Inheritence).封装(Encapsulation).多态(Polymorphism)2. 封装:类包含了数据与方法,将数据与方法放在一个类中就构成 ...
- JS 之JSON
JSON是Javascript中的对象,其简单理解为下:
- javascript控制cookie
参考:http://www.cnblogs.com/ly312/archive/2010/07/14/1777190.html function getCookies(name) { var arr ...
- HTML5 中的Nav元素详解
什么是Nav元素 Nav元素可以用作页面导航的链接组,在导航链接组里面有很多的链接,点击每个链接可以链接到其他页面或者当前页面的其他部分,并不是所有的链接组都要被放在nav元素里面,我们只需要把最主要 ...
- IRLS(迭代加权最小二乘)
IRLS用于解决这种目标函数的优化问题(实际上是用2范数来近似替代p范数,特殊的如1范数). 可将其等价变形为加权的线性最小二乘问题: 其中W(t)可看成对角矩阵,每步的w可用下面的序列代替 如果 p ...