首页 > 其他 > 详细

sublime_Text3中snippet设置信息头(包括作者、日期)

时间:2017-06-11 11:53:22      阅读:592      评论:0      收藏:0      [点我收藏+]

1.tool->new snippet 创建一个新的snippet,并保存为author.sublime-snippet(最好在该目录(User)下再创建一个MySnippet目录):
其内容:

 1 <snippet>
 2 <content><![CDATA[
 3 /**
 4  * ============================
 5  * @Author:   XX
 6  * @Version:  1.0 
 7  * @DateTime: ${1:alt+t}
 8  * ============================
 9  */
10 ]]></content>
11     <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
12     <tabTrigger>author</tabTrigger>
13     <!-- Optional: Set a scope to limit where the snippet will trigger -->
14     <!-- <scope>source.python</scope> -->
15 </snippet>

 

2.Tools → New Plugin。创建时间插件,保存在User目录,命名为addCurrentTime.py:
其内容为:

1 import sublime, sublime_plugin
2 import datetime
3 class AddCurrentTimeCommand(sublime_plugin.TextCommand):
4     def run(self, edit):
5         self.view.run_command("insert_snippet", 
6             {
7                 "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") 
8             }
9         )

 

3.Preference → Key Bindings - User。绑定快捷键:

其内容为:

1 [
2     {
3         "command": "add_Info",
4         "keys": [
5             "alt+t"
6         ]
7     }
8 ]

 

4.验证。
在sublime Text3中新建一个文件,在文中输入author,然后按Tab键,便可出现信息头,但是时间没有显示,不急,这时候按时间绑定快捷键(alt+t).大功告成!

截图:

输入author,然后按Tab键:

技术分享

按组合键(alt+t)后:

技术分享

sublime_Text3中snippet设置信息头(包括作者、日期)

原文:http://www.cnblogs.com/xiaomingzaixian/p/6984664.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!