2016-12-04 79 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

非常感謝,現在工作得很好。 –

相關問題