sublime&&Hbuilder扩展常用代码块
2016-08-11 18:46
435 查看
一、sublime
1、tools-developer-New snippet获得如下模板:<snippet> <content><![CDATA[ Hello, ${1:this} is a ${2:snippet}. ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <!-- <tabTrigger>hello</tabTrigger> --> <!-- Optional: Set a scope to limit where the snippet will trigger --> <!-- <scope>source.python</scope> --> </snippet>
content—输出表达式内容
tabTrigger—提示快捷键
${1:this}—默认补全代码之后的光标位置及默认内容this.
${2:snippet}—补全代码之后按tab键光标的第二默认位置及内容
2、遵循如上规则对模板就行修改,例如:
<snippet> <content><![CDATA[ <a href="${1:this}" title="">${2:snippet}</a> ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>a</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <!-- <scope>source.python</scope> --> </snippet>
3、将文件以 sublime-snippet 为后缀保存在Sublime Text 3\Packages\User默认目录下,就完成了对以a作为快捷键的代码块的创建保存。任意输入a+tab就能方便的调用保存好的代码块
<a href="this" title="">snippet</a>
二、Hbuilder
工具—扩展代码块–自定义html代码块进入代码块模板之后按提示添加自定义代码块
#可复制一段命令,在下面开始制作新命令 snippet 'img_a_src' do |cmd| #div_class是显示名称,代码助手提示列表显示时可见 cmd.trigger = 'img_a_src' #divc是激活字符,即按下divc后会触发该代码块 cmd.expansion = "<img src=\"$1\" alt=\"\" title=\"\" />$0" #expansion是代码块的输出内容,其中$0、$1是光标的停留和切换位置。$1是第一个停留光标,$0是最后回车时停留的光标。 #如果输出涉及到换行和tab,也需严格在这里使用换行和tab。 #输出双引号在前面加\来转义,输出$使用\$(单引号中)或\\$(双引号中)转义 cmd.needApplyReContentAssist = true #这句话的意思是输出后同时激活代码助手,即在$1的位置直接拉出样式列表 end #div_class代码块结束 snippet 'ng-pluralize' do |cmd| cmd.trigger = 'ngp' cmd.expansion = "<ng-pluralize>$1</ng-pluralize>" end
保存–完成!!
相关文章推荐
- 详解Ruby中的代码块及其参数传递
- 深入浅析Java中普通代码块、构造代码块与静态代码块
- iOS 代码块(block)使用基础
- Java中几种代码块的分析
- 黑马程序员_java中代码块的概念--单态设计模式
- Java学习笔记——静态代码块,构造代码块,构造函数间的执行顺序
- Java学习笔记——面试常客:写出一个死锁的例子
- 输出结果是什么?这颗子弹犀利不?(静态代码块)
- Java中的引用传递和代码块
- 黑马程序员——java小结_008 _代码块的优先级
- 黑马程序员_java的四种代码块
- python3-markdown 解析反引号代码块与代码高亮
- 用宏定义的形式书写代码块
- Java中普通代码块,构造代码块,静态代码块区别及代码示例
- java 代码块
- oop 静态方法,成员方法 ,调用
- Java中的4种代码块
- 关于java中的非静态代码块和静态代码块
- 静态、三大代码块以及对象的创建过程
- 黑马程序员--Java基础之面向对象(下)