Sublime Text Tips

Some things I do to mtigate day-to-day pains.

A shortcut to copy current file’s path:

{ "keys": ["super+i"], "command": "copy_path" },

Create snippet for things you repeatedly typing over 5 times (Tools > Developer > New Snippet). The snippet name’s suffix needs to be .sublime-snippet.

Need to add timestamp constantly? Add a python script to ~/Library/Application Support/Sublime Text/Packages/User/add_date_time.py:

import datetime
import getpass
import sublime
import sublime_plugin

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

Then bind to a keyboard shortcut:

{ "keys": ["command+shift+d"], "command": "add_date_time" },

Add a key to spell check:

{ "keys": ["option+s"], "command": "toggle_setting", "args": {"setting": "spell_check"} },