add time and date like editplus in sublime text

From WebHostingNeeds.com
Jump to: navigation, search

Go to

Tools > Developer > New Plugin

Add

import sublime
import sublime_plugin
import datetime, getpass

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

class AddTimeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.run_command("insert_snippet", { "contents": "%s" %  datetime.datetime.now().strftime("%I:%M:%S %p") } )

Save it as

.config/sublime-text-3/Packages/User/add_date.py

On Windows

%AppData%\Roaming\Sublime Text 3\Packages\User\add_date.py


Go to

Preferences > Key Bindings

Add

[
    {"keys": ["ctrl+alt+;"], "command": "add_date" },
    {"keys": ["ctrl+shift+;"], "command": "add_time" },
]

Now to get date, press

Ctrl+Alt+;



sublime