HBuilder CSS 自定义代码块

  1 =begin
  2 本文档是CSS代码块的编辑文件。注意不要把其他语言的设置放到css里来。
  3 HBuilder可使用ruby脚本来编辑代码块和增强操作命令。
  4 1、编辑代码块
  5 如果要新增一个代码块,复制如下一段代码到空白行,然后设定参数。
  6     ‘userselect:none‘是代码块的显示名字;
  7     s.trigger = ‘usn‘ 是设定激活字符,比如输入usn会在代码提示时显示该代码块;
  8     s.expansion = ‘‘ 是设定该代码块的输出字符,其中$0、$1是光标的停留和切换位置。
  9 snippet "userselect:none" do |s|
 10     s.trigger = "usn"
 11     s.expansion = ‘-webkit-user-select: none;
 12 -moz-user-select: none;
 13 -ms-user-select: none;‘
 14 end
 15 2、编辑按键命令
 16 如果要新增一个按键操作命令,复制如下一段代码到空白行,然后设定参数。
 17 ‘Br‘是命令名字;
 18 s.key_binding = ‘CONTROL+ENTER‘ 是设定按什么快捷键可以触发这个命令;
 19 s.expansion = ‘<br/>‘ 是设定输出字符。
 20 snippet ‘Br‘ do |s|
 21   s.key_binding = ‘CONTROL+ENTER‘
 22   s.expansion = ‘<br/>‘
 23 end
 24 以上以html代码块做示例,css代码块类似,使用时注意避免混淆
 25 操作时注意冲突,注意备份,有问题就还原。
 26 多看看已经写的ruby命令,会发现更多强大技巧。
 27 修改完毕,需要重启才能生效。
 28 玩的愉快,别玩坏!
 29 脚本开源地址 https://github.com/dcloudio/HBuilderRubyBundle ,可以把你的配置共享到这里,也可以在这里获取其他网友的版本
 30 =end
 31
 32 require ‘ruble‘
 33
 34 with_defaults :scope => "source.css support.type.property-name.css" do
 35
 36 #  snippet "!important CSS" do |s|
 37 #    s.trigger = "!"
 38 #    s.expansion = "${1:!important}"
 39 #  end
 40
 41   snippet "-webkit-" do |s|
 42     s.trigger = "webkit"
 43     s.needApplyReContentAssist = true
 44     s.expansion = ‘-webkit-‘
 45   end
 46
 47   snippet "-moz-" do |s|
 48     s.trigger = "moz"
 49     s.needApplyReContentAssist = true
 50     s.expansion = ‘-moz-‘
 51   end
 52
 53   snippet "-ms-" do |s|
 54     s.trigger = "ms"
 55     s.needApplyReContentAssist = true
 56     s.expansion = ‘-ms-‘
 57   end
 58
 59   snippet "background: image repeat attachment position" do |s|
 60     s.trigger = "bg"
 61     s.needApplyReContentAssist = true
 62     s.expansion = "background: url($1) ${2:repeat/repeat-x/repeat-y/no-repeat} ${3:scroll/fixed} ${4:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0"
 63   end
 64
 65   snippet "background-color" do |s|
 66     s.trigger = "bc"
 67     s.expansion = "background-color: $1"
 68     s.needApplyReContentAssist = true
 69   end
 70
 71   snippet "background-color: \#" do |s|
 72     s.trigger = "bch"
 73     s.expansion = "background-color: \#$1"
 74     s.needApplyReContentAssist = true
 75   end
 76
 77   snippet "background-color: rgb" do |s|
 78     s.trigger = "bcr"
 79     s.expansion = "background-color: rgb(${1:255},${2:255},${3:255})"
 80   end
 81
 82   snippet "background-image" do |s|
 83     s.trigger = "bi"
 84     s.expansion = "background-image: $1"
 85     s.needApplyReContentAssist = true
 86   end
 87
 88   snippet "background-image: url" do |s|
 89     s.trigger = "biu"
 90     s.expansion = "background-image: url($1)"
 91     s.needApplyReContentAssist = true
 92   end
 93
 94   snippet "background-position" do |s|
 95     s.trigger = "bp"
 96     s.expansion = "background-position: $1"
 97     s.needApplyReContentAssist = true
 98   end
 99
100   snippet "border-color" do |s|
101     s.trigger = "boc"
102     s.expansion = ‘border-color: $1‘
103     s.needApplyReContentAssist = true
104   end
105
106   snippet "border-style" do |s|
107     s.trigger = "bs"
108     s.expansion = ‘border-style: $1‘
109     s.needApplyReContentAssist = true
110   end
111
112   snippet "border-width" do |s|
113     s.trigger = "bw"
114     s.expansion = ‘border-width: $1‘
115     s.needApplyReContentAssist = true
116   end
117
118   snippet "display: none" do |s|
119     s.trigger = "dn"
120     s.expansion = ‘display: none‘
121   end
122
123   snippet "overflow: hidden" do |s|
124     s.trigger = "ovh"
125     s.expansion = ‘overflow: hidden‘
126   end
127
128   snippet "display: block" do |s|
129     s.trigger = "db"
130     s.expansion = ‘display: block‘
131   end
132
133   snippet "font-family: family" do |s|
134     s.trigger = "ff"
135     s.expansion = ‘font-family: $1‘
136     s.needApplyReContentAssist = true
137   end
138
139   snippet "font-size: size" do |s|
140     s.trigger = "fsize"
141     s.expansion = ‘font-size: $1‘
142     s.needApplyReContentAssist = true
143   end
144
145   snippet "height length" do |s|
146     s.trigger = "hei"
147     s.expansion = ‘height ${1}px;$0‘
148   end
149
150   snippet "list-style-image: url" do |s|
151     s.trigger = "lsi"
152     s.expansion = ‘list-style-image: url($1);‘
153     s.needApplyReContentAssist = true
154   end
155
156   snippet "properties { } ( } )" do |s|
157     s.trigger = "{"
158     s.expansion = ‘{
159     /* $1 */
160     $0
161 ‘
162   end
163   # FIXME Doesn‘t work
164   snippet "scrollbar" do |s|
165     s.trigger = "scrollbar"
166     s.expansion = ‘scrollbar-base-color:       ${1:#CCCCCC};
167 scrollbar-arrow-color:      ${2:#000000};
168 scrollbar-track-color:      ${3:#999999};
169 scrollbar-3dlight-color:    ${4:#EEEEEE};
170 scrollbar-highlight-color:  ${5:#FFFFFF};
171 scrollbar-face-color:       ${6:#CCCCCC};
172 scrollbar-shadow-color:     ${7:#999999};
173 scrollbar-darkshadow-color: ${8:#666666};‘
174   end
175
176   snippet "text-align: left" do |s|
177     s.trigger = "tal"
178     s.expansion = ‘text-align: left;‘
179   end
180
181   snippet "text-align: center" do |s|
182     s.trigger = "tac"
183     s.expansion = ‘text-align: center;‘
184   end
185
186   snippet "text-align: right" do |s|
187     s.trigger = "tar"
188     s.expansion = ‘text-align: right;‘
189   end
190
191   snippet "text-transform" do |s|
192     s.trigger = "tt"
193     s.expansion = ‘text-transform: $1‘
194     s.needApplyReContentAssist = true
195   end
196
197   snippet "width length" do |s|
198     s.trigger = "wid"
199     s.expansion = ‘width: ${1}px;$0‘
200   end
201
202   snippet "margin-top" do |s|
203     s.trigger = "mgt"
204     s.expansion = ‘margin-top: $1‘
205   end
206
207   snippet "userselect:none" do |s|
208     s.trigger = "usn"
209     s.expansion = ‘-webkit-user-select: none;
210 -moz-user-select: none;
211 -ms-user-select: none;‘
212   end
213 end
214
215 with_defaults :scope => "source.css entity.name.tag.css" do
216   snippet "@font-face" do |s|
217     s.trigger = "@fontface"
218     s.locationType="CSS_OUTRULE"
219     s.expansion = ‘@font-face {
220     font-family:$1;
221     src: url($2);
222 }‘
223   end
224
225   snippet "@import" do |s|
226     s.trigger = "@import"
227     s.locationType="CSS_OUTRULE"
228     s.expansion = ‘@import url("${1:global.css}");‘
229   end
230
231   snippet "@charset" do |s|
232     s.trigger = "@charset"
233     s.locationType="CSS_OUTRULE"
234     s.expansion = ‘@charset "${1:utf-8}";‘
235   end
236
237   snippet "@page" do |s|
238     s.trigger = "@page"
239     s.locationType="CSS_OUTRULE"
240     s.expansion = ‘@page:${1:first/left/right}{
241
242 }‘
243   end
244   snippet "@keyframes" do |s|
245     s.trigger = "@keyframes"
246     s.locationType="CSS_OUTRULE"
247     s.expansion = ‘@keyframes ${1:name}{
248     from{$2}
249     to{$3}
250 }‘
251   end
252
253   snippet "@-moz-keyframes" do |s|
254     s.trigger = "@keyframes"
255     s.locationType="CSS_OUTRULE"
256     s.expansion = ‘@-moz-keyframes ${1:name}{
257     from{$2}
258     to{$3}
259 }‘
260   end
261
262   snippet "@-ms-keyframes" do |s|
263     s.trigger = "@keyframes"
264     s.locationType="CSS_OUTRULE"
265     s.expansion = ‘@-ms-keyframes ${1:name}{
266     from{$2}
267     to{$3}
268 }‘
269   end
270
271   snippet "@-webkit-keyframes" do |s|
272     s.trigger = "@keyframes"
273     s.locationType="CSS_OUTRULE"
274     s.expansion = ‘@-webkit-keyframes ${1:name}{
275     from{$2}
276     to{$3}
277 }‘
278   end
279
280   snippet "@document" do |s|
281     s.trigger = "@document"
282     s.locationType="CSS_OUTRULE"
283     s.expansion = ‘@document ${1:url/url-prefix/domain/regexp}("$2") {
284     $3
285 }‘
286   end
287
288   snippet "@supports" do |s|
289     s.trigger = "@supports"
290     s.locationType="CSS_OUTRULE"
291     s.expansion = ‘@supports(${1:prop}:${2:value}) {
292     $3
293 }‘
294   end
295
296   snippet "@namespace" do |s|
297     s.trigger = "@namespace"
298     s.locationType="CSS_OUTRULE"
299     s.expansion = ‘@namespace ${1:prefix} "$2";‘
300   end
301
302
303   snippet "@media" do |s|
304     s.trigger = "@media"
305     s.locationType="CSS_OUTRULE"
306     s.expansion = ‘@media only screen and (min-width: $1px) {
307     $2
308 }‘
309   end
310 end
时间: 2024-11-03 22:28:44

HBuilder CSS 自定义代码块的相关文章

HBuilder HTML 自定义代码块

1 =begin 2 本文档是HTML代码块的编辑文件.注意不要把其他语言的设置放到html里来. 3 HBuilder可使用ruby脚本来编辑代码块和增强操作命令. 4 1.编辑代码块 5 如果要新增一个代码块,复制如下一段代码到空白行,然后设定参数. 6 'Style'是代码块的显示名字: 7 s.trigger = 'style' 是设定激活字符,比如输入style均会在代码提示时显示该代码块: 8 s.expansion = '' 是设定该代码块的输出字符,其中$0.$1是光标的停留和切

HBuilder js 自定义代码块

1 =begin 2 本文档是HBuilder预置的js代码块的文件.注意不要把其他语言的设置放到js里来. 3 如果用户修改此文档,HBuilder升级后会覆盖用户的修改,建议进入菜单 工具→扩展代码块 扩展相应的代码块. 4 若修改本文档,需要重启才能生效.修改过程中注意备份. 5 脚本开源地址 https://github.com/dcloudio/HBuilderRubyBundle 6 1.编辑代码块 7 如果要新增一个代码块,复制如下一段代码到空白行,然后设定参数. 8 snippe

vscode自定义代码块

vscode中设置自定义代码块打开首选项,选择用户代码片段,打开后选择编程语言选中后打开文件,按照格式编辑内容 "Print to console log": { "prefix": "csl", "body": [ "console.log('$1')" ], "description": "log output to console" },

Xcode自定义代码块

到现在才发现原来Xcode有自定义代码块这么神奇的功能,能简化很多无聊的敲重复代码的工作,真是感叹我怎么才知道!!! 具体的设置流程见:http://nshipster.cn/xcode-snippets/   或者 http://www.sufeinet.com/thread-8732-1-1.html 然后我也把自己常用的几个写好了放到的github上:   https://github.com/Phelthas/LXMSnippets 使用方法: 将这些.codesnippet文件copy

xcode 迁移自定义代码块

 iOS Xcode自定义代码块迁移 Command + Shift + G. 前往如下路径的文件夹 路径 : ~/Library/Developer/Xcode/UserData/CodeSnippets 把文件夹内部的文件复制, 粘贴到另一台电脑的Xcode同样的文件夹中即可 重启xcode 转自:https://www.jb51.net/article/159859.htm 原文地址:https://www.cnblogs.com/qingzZ/p/12069354.html

iOS:自定义代码块{ }

1.Xcode本身带有编码常用的代码块可供使用,如下图 调用方法: (1)直接拖到代码区域中: (2)使用快捷键,键入 “while”, Xcode就会出现自动完成的提示 也可以自定义自己常用的代码块: (1)编写代码 (2)选中代码,在选择的代码上长按鼠标左键直至光标符号变成鼠标图案,或者没有鼠标时,按下Control键后将代码拖动. (3)拖放到块代码区 (4)点击图标,打开代码区 (5)“Edit”,进行设置 (6设置块代码名字,快捷提示 (7)设置可替换字符将 @"Cell"

eclipse自定义代码块折叠

下载插件 com.cb.eclipse.folding_1.0.6.jar 下载地址:http://files.cnblogs.com/haiq/代码折叠插件_com.cb.eclipse.folding_1.0.6.rar 2.将插件放在Eclipse安装目录eclipse\plugins下面 3.重启eclipse 4.启动eclipse,点击 Windows-Preferences-Java-Editor-Folding,在"Select folding to use:"处选择&

在Xcode中自定义代码块——快速代码

在Xcode中自定义自己的快速代码,很简单,用起来也很方便 首先选择自己想要的自定义的代码块 拖拽到红框的区域松手,会弹出设置窗口 这是我的填写 这里有另外一个技巧,可以给自己想要改变的地方设置成预留字(预留字是我自己随口胡邹的名词) 总之,如果你想把button的title设置成可变的,就在代码块中把 [button setTitle:@"button" forState:UIControlStateNormal]; 改为 [button setTitle:@"<#b

VS自定义代码块Code Snippet

一  .简述 我们在开发当中,避免不了一些重复的开发工作,在你漫长的开发以及学习当中,你会发现有这么一部分代码是你时常会使用到的.我想这个工具也是针对这个原因出来的吧,它就是预先把你需要的这部分代码的主干部分给它提练出来,然后你只要修改局部的某些部分内容,从而完成你代码的编辑工作.这样的好处,就是当你使用一个快捷键的方式,就可以把你这部分常用的代码直接插入到你需要的代码文件当中.而不需要你由头到尾地重复一些额外的工作,缩短你的开发时间,提高你的工作效率.这就是今天要说到的Code Snippet