【发布时间】:2017-10-13 07:23:10
【问题描述】:
我在 Preferences - Browse Packages - User (folder) 中创建了这个whatever.py 文件
import sublime, sublime_plugin, time
class InsertDatetimeCommand(sublime_plugin.TextCommand):
def run(self, edit):
sel = self.view.sel();
for s in sel:
self.view.replace(edit, s, time.strftime( '%H:%M %d/%m/%Y' ))
然后
在首选项 - 键绑定 - 用户中,添加了这一行:
{ "keys": ["f5"], "command": "insert_datetime"}
按 F5 可以按预期工作,我可以插入日期时间,但是当我这样做时,这个日期时间被选中,当我按 Enter 进入换行符时,它被删除。你知道我应该在上面的代码中更改哪个部分以在按 F5 后不选择所有日期时间字符串吗?
【问题讨论】:
标签: python sublimetext3