Emme自动完成功能不适用于Sublime中的php文件(扩展缩写)

时间:2016-12-04 14:19:49

标签: php sublimetext3 emmet

我在Sublime中使用Emmet插件来处理HTML文件。但是当我想在像Laravel中的视图文件这样的PHP文件中键入HTML代码时,Emmet不会扩展缩写。

例如:当我输入html:5并在Sublime中的HTML文件中按Tab键时,Emmet自动完成功能会将其转换为:

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

  </body>
</html>

但是当我在扩展名为.php且压缩标签的文件中执行相同操作时,不会发生任何事情。这是一个崇高的配置问题,还是有任何解决方案可以在Sublime中用PHP文件快速输入Emmet的HTML代码?

1 个答案:

答案 0 :(得分:1)

Emmet的Package Control page中的自述文件清楚地解释了如何执行此操作 - 向下滚动到How to expand abbreviations with Tab in other syntaxes部分:

  

Emmet仅扩展有限语法中的缩写:HTML,CSS,LESS,SCSS,Stylus和PostCSS。将Tab处理程序限制为有限语法列表的原因是因为它破坏了原生Sublime Text片段。

     

如果您想在其他语法中使用Tab缩写(例如,JSX,HAML等),则必须调整键盘shorcuts设置:为tab键添加expand_abbreviation_by_tab命令以获取所需的语法范围选择器。要获取当前语法范围选择器,请按⇧^P(OSX)或 Ctrl + Alt + Shift + P ,它将显示在编辑器状态栏中。

     

转到Preferences > Key Bindings — User并使用正确配置的范围选择器而不是SCOPE_SELECTOR令牌插入以下JSON代码段:

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