SublimeText3 snippet 编写总结
SublimeText3 snippet 编写总结
SublimeText的snippet定义功能也十分强大, 类似VAssist.
在菜单tool->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><![CDATA[ 和 ]]></content>之前为要定义的内容块,
在 <tabTrigger> 与 </tabTrigger> 之间定义快捷名称,
在 <scope> 与 </scope> 之间定义该snippet作用的文件类型.
例如当需要输入html5这几个字符后按tab, 自动提示要输入的代码片段:
下面是我的html5 snippet
<snippet>
<content><![CDATA[
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>${1}</title>
</head>
<body>
<header>
Hello, ${1:this} is a ${2:snippet}!
</header>
<nav>${3:nav}</nav>
<article>
<section>${4:section}</section>
</article>
<aside>${5:aside}</aside>
<footer>${6:footer}</footer>
</body>
</html>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>html5</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>index.html</scope>
</snippet>
编写好此文件后ctrl+s保存,此时会弹出默认的保存路径, 一般是..\Data\Packages\User下,
文件后缀名必须是.sublime-snippet。
我这里保存为html5.sublime-snippet或者您可以保存为其他的名称.
同一个snippet只能有一个。
${1}表示补全光标默认停留的位置, 编辑${1}完成后按tab可以跳转到${2}的位置,
this表示2处默认内容,完成${2}后,按tab之后会选中${3:snippet},同理以此类推。
关于<scope>,这里是官方定义的内容,如下:
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
CSS: source.css
D: source.d
Diff: source.diff
Erlang: source.erlang
Go: source.go
GraphViz: source.dot
Groovy: source.groovy
Haskell: source.haskell
HTML: text.html(.basic)
JSP: text.html.jsp
Java: source.java
Java Properties: source.java-props
Java Doc: text.html.javadoc
JSON: source.json
Javascript: source.js
BibTex: source.bibtex
Latex Log: text.log.latex
Latex Memoir: text.tex.latex.memoir
Latex: text.tex.latex
LESS: source.css.less
TeX: text.tex
Lisp: source.lisp
Lua: source.lua
MakeFile: source.makefile
Markdown: text.html.markdown
Multi Markdown: text.html.markdown.multimarkdown
Matlab: source.matlab
Objective-C: source.objc
Objective-C++: source.objc++
OCaml campl4: source.camlp4.ocaml
OCaml: source.ocaml
OCamllex: source.ocamllex
Perl: source.perl
PHP: source.php
Regular Expression(python): source.regexp.python
Python: source.python
R Console: source.r-console
R: source.r
Ruby on Rails: source.ruby.rails
Ruby HAML: text.haml
SQL(Ruby): source.sql.ruby
Regular Expression: source.regexp
RestructuredText: text.restructuredtext
Ruby: source.ruby
SASS: source.sass
Scala: source.scala
Shell Script: source.shell
SQL: source.sql
Stylus: source.stylus
TCL: source.tcl
HTML(TCL): text.html.tcl
Plain text: text.plain
Textile: text.html.textile
XML: text.xml
XSL: text.xml.xsl
YAML: source.yaml
SublimeText3 snippet 编写总结的更多相关文章
- sublime text3 之snippet编写代码片段
sublime text 3 中有个强大的功能就是可以编写各种文件类型的snippet代码片段,可以节省大量的时间. 文件名为:jekyll-top.sublime-snippet(.sublime- ...
- 我的Emacs折腾经验谈(四) 也谈Yasnippet
又是好久没更新了,不过还好,现在慢慢有点感觉了,好长时间不写博客会心里有点感觉欠一点什么东西.觉得每次写了东西都往主页推搞得压力好大,以后就不往网站首页推了,纯留下来供参考,另外就是主要方便从搜索找过 ...
- sublimeText 3使用教程
工欲善利其事必先利其器,sublime作为一款轻量.便捷的编译工具,集成了很多插件,功能强大,深受大家的喜爱.掌握好sublime的具体用法,必会为你的工作带来极大的便利!好了,闲话不多说了,下面开始 ...
- vim-snipmate编写snippet的语法
vim-snipmate真的很好用,以前好多编写代码的问题得到完美的解决.还附带提升我对vim的理解和信心,在这里感谢一下作者.thank you. 1.现说一下我浓缩的重要语法. 1.定义是下面这样 ...
- 【APICloud】利用sublimetext3编写apicloud
下载sublime text 3 安装插件 使用模糊搜索apicloud有三个插件全部下载下来 安装海马玩模拟器,这是一个安卓的模拟器,进入官网下载后直接安装就可以了. 打开sublime text ...
- 使用 Code Snippet 简化 Coding
在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...
- Visual Studio 如何使用代码片段Code Snippet提高编程速度!!!
使用Code Snippet简化Coding 在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符 ...
- 手把手教你写Sublime中的Snippet
手把手教你写Sublime中的Snippet Sublime Text号称最性感的编辑器, 并且越来越多人使用, 美观, 高效 关于如何使用Sublime text可以参考我的另一篇文章, 相信你会喜 ...
- VS开发中的代码编写小技巧——避免重复代码编写的几种方法
上一篇文章中程序员的幸福生活--有你的日子,每天都是情人节,收到了大家的很多好评.鼓励和祝福,非常感动,真诚的谢谢大家.也希望每个朋友都能保持一个积极向上的心态,去迎接丰富多彩的人生. 在开发过程中, ...
随机推荐
- 分布式任务调度平台XXL-Job搭建
下载: https://github.com/xuxueli/xxl-job 下载 然后倒入到自己的工程里面 引入后: 导入数据:跑一边 导入: 修改: Window -->show view- ...
- Linux bash shell环境变量以及语法规范
摘自: http://blog.csdn.net/abc_ii/article/details/8762739
- iOS 如何查看app提交审核是否使用广告标识符(IDFA)
相信很多人被苹果拒绝过 : 您的 App 正在使用广告标识符 (IDFA).您必须先提供关于 IDFA 的使用信息或将其从 App 中移除,然后再上传您的二进制文件. 那么如何查看app里哪里用到ID ...
- asterisk ss7 ${CALLERID(rdnis)}变量为空问题
asterisk 1.8.16+chan_ss7 version 2.1.1b ${CALLERID(rdnis)}变量取不到信息问题,解决 编辑 funcs/func_callerid.c chan ...
- Loading 遮蔽层 简单实现。
<!--背景div--><div id="bg" class="bg" style="display:none;text-align ...
- 二:apache的Qpid消息中间件介绍
一:什么是Qpid?--->Qpid 是 Apache 开发的一款面向对象的消息中间件,它是一个 AMQP 的实现,可以和其他符合 AMQP 协议的系统进行通信.--->Qpid 提供了 ...
- CodeForces - 123E Maze
http://codeforces.com/problemset/problem/123/E 题目翻译:(翻译来自: http://www.cogs.pw/cogs/problem/problem.p ...
- 【LeetCode】064. Minimum Path Sum
题目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right w ...
- 打印菱形(Print Diamond/Lozenge)
→ ↓ * * * * * * * * * * * * * 总结了一下关于打印菱形的思路. 通常是从循环变量之间的映射关系入手,推导出相应的公式.这 ...
- AI-Info-Micron-Insight:Intelligence Accelerated™
ylbtech-AI-Info-Micron-Insight:Intelligence Accelerated™ Intelligence Accelerated™ Micron Insight 大会 ...