2

我习惯于在.html文件中进行 zen 编码,它可以工作!但是我不知道当我在文件中时如何做同样的事情,也.php尝试过ctrl++但什么也没发生。我在一个 Joomla 网站上工作,所以主题文件会在里面而不是在里面,但是有很多 HTML 标签要输入。我什至尝试添加此设置并将其保存在用户文件夹中,但没有任何反应。为什么它不起作用?这是我从链接获得参考的地方,但是它在 Zen Coding.js 中使用,但即使在 ST2 中语法也是相同的。片段只是附加设置,但主要是 HTML zen-coding 缩写不会出现在文件中,但它可以在. 任何人都可以解决这个问题?altenter.php.htmlzen-coding.sublime.settings.php.html

"my_zen_settings" : {
    "html": {
        "filters": "php,html",
        "abbreviations": {
            "jq": "<script src='jquery.js' type='javascript'>",
            "demo": "<div id=\"demo\"></div>"
        }
    },
    "css": {
        "filters": "html,css,fc",
        "snippets": {
            "c": "color:#${1:000000};"
        }
    },
    "php": {
       "filters": "php,html",
       "snippets": {
            "php":          "<?php | ?>",
            "php:info":     "<?php\nphpinfo();\n?>",
            "php:echo":     "<?php echo | ?>",

            "php:Ns":       "<?php\nnamespace |;\n\t\n?>",
            "php:ns":       "namespace |;",

            "php:Class":    "<?php\nclass |\n{\n\t\n}\n?>",
            "php:class":    "class |\n{\n\t\n}",

            "php:Function": "<?php\nfunction |() {\n\t\n}\n?>",
            "php:function": "function |() {\n\t\n}",

            "php:Var":      "<?php $| = ; ?>",
            "php:var":      "$| = ;",

            "php:Object":   "<?php $| = (object) ; ?>",
            "php:object":   "$| = (object) ;",

            "php:New":      "<?php $| = new ; ?>",
            "php:new":      "$| = new ;",

            "php:Bool":     "<?php $| = FALSE; ?>",
            "php:bool":     "$| = FALSE;",

            "php:Array":    "<?php $| = array(); ?>",
            "php:array":    "$| = array();",


            "php:Array+":   "<?php |[] = ; ?>",
            "php:array+":   "|[] = ;",

            "php:Array-":   "<?php unset($|[]); ?>",
            "php:array-":   "unset($|[]);",

                        //hack $|, seems to replace $i with $1
            "php:For":      "<?php\nfor ($|i = 0; $|i < |; $|i++) {\n\t\n}\n?>",
            "php:for":      "for ($|i = 0; $|i < |; $|i++) {\n\t\n}",

            "php:Foreach":  "<?php\nforeach (| as ) {\n\t\n}\n?>",
            "php:foreach":  "foreach (| as ) {\n\t\n}",

            "php:While":    "<?php\nwhile(|) {\n\t\n}\n?>",
            "php:while":    "while(|) {\n\t\n}",

            "php:Dowhile":  "<?php\ndo {\n\t\n} while(|);\n?>",
            "php:dowhile":  "do {\n\t\n} while(|);",

            "php:If":       "<?php if( | ) { ?>\n\t\n<?php }?>",
            "php:if":       "if( | ) {\n\t\n}",

            "php:Ifelse":   "<?php if( | ) { ?>\n\t\n<?php } else { ?>\n\t\n<?php }?>",
            "php:ifelse":   "if( | ) {\n\t\n} else {\n\t\n}",

            "php:Switch":   "<?php switch( | ) { \n\tcase :\n\t\t\n\t\tbreak;\n\tdefault :\n\t\t\n\t\tbreak;\n}\n?>",
            "php:switch":   "switch( | ) { \n\tcase :\n\t\t\n\t\tbreak;\n\tdefault :\n\t\t\n\t\tbreak;\n}",

            "php:Include":  "<?php include \"|\"; ?>",
            "php:include":  "include \"|\";",

            "php:Include1": "<?php include_once \"|\"; ?>",
            "php:include1": "include_once \"|\";"
        }
    }
}
4

3 回答 3

3

有同样的问题。尝试了以下方法:

  1. 首选项 > 浏览包 > 默认 (OSX).sublime-keymap
  2. 找到“操作数”索引,其中“键”= ctrl + alt + enter
  3. 将“text.php”添加到该字符串。像这样:“source.css - source.css.embedded, text.xml, text.html -source -meta.tag, meta.scope.between-tag-pair.html -source, text.php”

这似乎奏效了。我希望这有帮助。

于 2012-05-15T07:37:13.727 回答
1

您可以为 Sublime Text 2 安装 Emmet: https ://github.com/sergeche/emmet-sublime

注意: Emmet(前 Zen 编码)。

于 2013-02-07T20:02:07.457 回答
0

将 text.php 添加到 Default (Windows).sublime-keymap 对我有用。

于 2013-04-27T19:46:06.080 回答