sublimtext快速插入appframework的html分页

  作者:木尘 日期:2014-11-26

sublimtext快速插入html分页:

1. 创建插件:

Tools → New Plugin:

import sublime_plugin
class AddAfHtmlCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.run_command("insert_snippet",
            {
                "contents":
                "<!DOCTYPE html>""\n"
                "<html>""\n"
				"   <head>""\n"
				"	   <title></title>""\n"
				"   </head>""\n"
				"   <body>""\n"
				"      <!--header头部-->""\n"
				"      <header id=\"#\">""\n"
				"         <h1>我是header</h1>""\n"
				"         <a href=\"#\" style=\"left:0.7em\">返回</a>""\n"
				"      </header>""\n"
				"      <!--header  end-->""\n"
				"      <!--content部分-->""\n"
				"      <div class=\"content\" >""\n"
				"      </div>""\n"
				"      <!--content end-->""\n"
				"      <!--footer底部  -->""\n"
				"      <footer id=\"#\">""\n"
				"      </footer>""\n"
				"      <!--footer end  -->""\n"
				"   </body>""\n"
				"   <script  type=\"text/javascript\">""\n"
				"   //进入这个页面时调用""\n"
				"   function myPageLoadedPanel() {""\n"
				"      //dosomething""\n"
				"   }""\n"
				"   //离开这个页面时调用""\n"
				"   function myPageUnloadedPanel(){""\n"
				"      //dosomething""\n"
				"   }""\n"
				"   </script>""\n"
				"</html>"
            }
        )


保存为Sublime Text 2\Packages\User\addAfHtml.py

2. 创建快捷键:

Preference → Key Bindings - User:

[
    {
        "command": "add_af_html",
        "keys": [
            "ctrl+shift+f5"
        ]
    }
]

3. 此时使用快捷键ctrl+shift+F5即可在当前光标处插入当前时间,如下:


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。