首页 > 其他分享 >Sublime Text 3 插入当前日期及时间

Sublime Text 3 插入当前日期及时间

时间:2023-10-14 09:34:38浏览次数:30  
标签:-% run Text self datetime 插入 Sublime

import datetime
import sublime_plugin
 
class AddCurrentTimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.run_command("insert_snippet",
            {
                "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d")
            }
        )

 

Sublime Text 3 是我平时最喜欢的 Coding 工具,没有之一,可以通过 Python 来 DIY 编写很多插件

打开 Sublime Text 3,点击菜单栏中 Preferences -> Browser Packages...

会弹出资源管理器,进入 User 文件,新建一个名为 addCurrentTime.py 的文件

添加以下内容:

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

在 Sublime Text 3 的菜单栏中点击 Preferences -> Key Bindings

在弹出窗口右边栏添加以下内容:

 
  1.   [
  2.   { "keys": ["ctrl+shift+,"], "command": "add_current_time" },
  3.   ]
 

以后要输入当前日期及时间,按组合键 Ctrl + Shift + ,即可

标签:-%,run,Text,self,datetime,插入,Sublime
From: https://www.cnblogs.com/csjoz/p/17763694.html

相关文章

  • app直播源代码,监听EditText输入框内输入内容的变化
    app直播源代码,监听EditText输入框内输入内容的变化输入框在开发中是一个很常见的控件,可能很多时候我们不仅仅是用来简单的用它来输入内容这么简单,有时候可能还需要拿到甚至是监听输入框里面的内容,然后作出一个合理的逻辑判断,对EditText监听安卓系统提供了TextWatcher来监听输入框......
  • 使用Apache POI往word模板中插入数据并转换文档格式
    word模板报告数据插入及格式转换1.向模板内写入数据1.1单文本插入//通过查询得到数据用参数或者对象接收后,与模板内参数对应完成文本插入Stringcode=usersService.findByCode().getCode();TestUsersbyCode=usersService.findByCode();Map<String,Object>data=ne......
  • 插入排序
    原数组为915623 1voidprint(vector<int>&a,intn,inti){2cout<<"step"<<i<<":";3for(intj=0;j<n;j++){4cout<<a[j]<<"";5}6......
  • vue中的v-text指令和v-html指令区别
    <html>  <head>  <metacharset="UTF-8">  <metaname="viewport"content="width=device-width,initial-scale=1.0">  <title>vue.js</title>  </head>  <body>    &......
  • Java通过itext解析PDF中的关键字得到坐标进行插入印章图片或签名
    需求因需提高公司运转效率,提倡去无纸化操作,减少人力等前提;通过系统将审核通过后的pdf文档进行盖电子印章或电子签名等功能;测试效果如下:图1图2实现思路因如上图1中,存在动态表格,所以文档的布局是随数据而变的,可能是多页,可能是一页,且内容上下浮动,所以得通过解析文档内容,通过......
  • excel 导出 The maximum length of cell contents (text) is 32767 characters Excel
    excel导出Themaximumlengthofcellcontents(text)is32767characters导出excel功能,报错。错误日志提示::Themaximumlengthofcellcontents(text)is32767characters调查后,poi会有单元格最大长度校验超过32767会报错。需求调研:调研发现,excel和csv文件本身存在......
  • CudaText 编译运行c
             CudaText是一款轻量级地文本编辑开源软件。在安装codeblocks的gcc编译器后可以编译运行c。配置如下打开Tools-->config-->Add。 其中Parameters设置如下为编译和运行。{FileName} -o {FileNameNoExt}&&cmd/c{FileNameNoExt} 按快......
  • Servlet.service() for servlet [dispatcherServlet] in context with path []
    一个不小心出现的错误,接口测试报500日志输出信息如下:[nio-8080-exec-2]o.a.c.c.C.[.[.[/].[dispatcherServlet]:Servlet.service()forservlet[dispatcherServlet]incontextwithpath[]threwexception[Requestprocessingfailed;nestedexceptionisjava.lang.Nu......
  • C++黑马程序员——P223-226. set容器 构造和赋值,大小和交换,插入和删除,查找和统计
    P223.set容器——构造和赋值P224.set容器——大小和交换P225.set容器——插入和删除P226.set容器——查找和统计P223.set容器构造和赋值特点:所有元素都会在插入时自动被排序本质:set/multiset属于关联式容器,底层结构是用二叉树实现。set和multiset的区别set不......
  • 获取当前输入光标(插入点的位置)
    oleacc.pas{*******************************************************}{}{CodeGearDelphiRuntimeLibrary}{}{......