【lua学习笔记】——在sublime中配置Lua运行环境

一、让Sublime可以运行lua脚本

打开sublime

选择tools-->Build System-->New Build System
 
在新出现的文件中输入如下内容:

{   

  "cmd": ["lua", "$file"],   

  "file_regex": "^(?:lua:)?[\t ](...*?):([0-9]*):?([0-9]*)",  

   "selector": "source.lua"

 }  

保存,名称为lua,保存在默认位置

重启电脑
按Ctrl+B就能Build lua文件
在最下方能看到运行结果

二、如何添加作者的信息---类似插件功能

Tools → New Plugin:

import datetime
import sublime_plugin
class AddInfoCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    self.view.run_command("insert_snippet",
    {
      "contents": "/**""\n"
      " * @Author: name""\n"
      " * @DateTime: " "%s" %datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") +"\n"
      " * @Description: Description""\n"
      " */"
    }
  )

保存为Sublime Text3\Packages\User\addAuthorInfo.py

三 如何创建快捷键

Preference → Key Bindings - User:

[
  {
    "command": "add_info",
    "keys": [
    "ctrl+shift+,"]
  }
]

 

posted @ 2017-06-24 18:59  ariboy  阅读(628)  评论(0编辑  收藏  举报