2016-12-04 58 views
0

我在Sublime中使用Emmet插件来处理HTML文件。但是,当我想在Laravel的视图文件等PHP文件中输入HTML代码时,Emmet并未扩展缩写。Emmet autocomplete不适用于Sublime中的php文件(展开缩写)

例如:当我在崇高的HTML文件键入html:5,按选项卡,然后埃米特自动完成将其转换为:

<!DOCTYPE html> 
    <html lang="en"> 
    <head> 
    <meta charset="UTF-8"> 
    <title>Document</title> 
    </head> 
    <body> 

    </body> 
</html> 

但是,当我做同样的与PHP扩展,并按文件标签什么都不会发生。这是一个崇高的配置问题,或有任何解决方案快速键入HTML代码Emmet Sublime PHP文件?

回答

1

在埃米特的Package Control page自述解释清楚如何做到这一点 - 向下滚动到How to expand abbreviations with Tab in other syntaxes部分:

埃米特扩大在有限的语法只有缩写:HTML,CSS,LESS,SCSS,手写笔和PostCSS。将Tab处理程序限制为有限语法列表的原因是因为它打破了原生Sublime Text片段。

如果您想在其他语法中使用Tab缩写(例如,JSX,HAML等),您必须调整键盘快捷键设置:添加expand_abbreviation_by_tab命令用于所需语法范围选择器的Tab键。为了得到当前的语法范围选择,按⇧^P(OSX)或按Ctrl + Alt键++P,它会显示在编辑器状态栏。

转到Preferences > Key Bindings — User并插入以下JSON片断与适当配置的范围选择,而不是SCOPE_SELECTOR令牌:

{ 
    "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" 
    } 
    ] 
} 

PHP的SCOPE_SELECTOR值为embedding.php text.html.basic

+0

非常感谢,现在工作得很好。 –