sublime text写jsx标签不自动补全
比如写
怎么办?
直接用Emmet写法写jsx中的html多爽呀
[
{
"keys": [
"super+e"
],
"args": {
"action": "expand_abbreviation"
},
"command": "run_emmet_action",
"context": [
{
"key": "emmet_action_enabled.expand_abbreviation"
}
]
},
{
"keys": [
"tab"
],
"command": "expand_abbreviation_by_tab",
"context": [
{
"operand": "source.js",
"operator": "equal",
"match_all": true,
"key": "selector"
},
{
"key": "preceding_text",
"operator": "regex_contains",
"operand": "(\\b(a\\b|div|span|p\\b|button)(\\.\\w*|>\\w*)?([^}]*?}$)?)",
"match_all": true
},
{
"key": "selection_empty",
"operator": "equal",
"operand": true,
"match_all": true
}
]
}
]
用emmet的写法,直接写div, 再按下tab键。举两个例子:
render() {
return (
div
)
}
光标在div后,按下tab键后
render() {
return (
<div></div>
)
}
render() {
return (
div.menu
)
}
光标在div.menu, 按下tab键后
render() {
return (
<div className="menu"></div>
)
}
嗯嗯,谢谢。用法我知道,问题是我的现在快捷键是:control + E 。不是tab键 而且用你的配置,我的sublime没效果,不知道什么原因,看上面我截图的配置过程。不过我按control + E有效果,怎么能切换快捷键,我也习惯用tab
复制进Preference->Package Settings->Emmet->Key Bindings - User里面
[
{
“keys”: [
“super+e”
],
“args”: {
“action”: “expand_abbreviation”
},
“command”: “run_emmet_action”,
“context”: [
{
“key”: “emmet_action_enabled.expand_abbreviation”
}
]
},
{
“keys”: [
“tab”
],
“command”: “expand_abbreviation_by_tab”,
“context”: [
{
“operand”: “source.js”,
“operator”: “equal”,
“match_all”: true,
“key”: “selector”
},
{
“key”: “preceding_text”,
“operator”: “regex_contains”,
“operand”: “(\b(a\b|div|span|p\b|button)(\.\w*|>\w*)?([^}]*?}$)?)”,
“match_all”: true
},
{
“key”: “selection_empty”,
“operator”: “equal”,
“operand”: true,
“match_all”: true
}
]
}
]