Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

The title should be rather explicit. When a file is created, I'd like to have a text automatically pasted at the top of it. The plugin would also be able to insert the text on existing files.

Of course, I'm thinking about a custom licence text. I saw this, but it requires a command in order to insert the text.

Does such a plugin exist for Sublime Text ?

share|improve this question

2 Answers

Just write a snippet on your own: http://docs.sublimetext.info/en/latest/extensibility/snippets.html

Or you could write a new plugin:

LicenseCommand.py

import sublime, sublime_plugin

class LicenseCommand(sublime_plugin.EventListener):
    def on_new(self, view):
    view.run_command("license_insert")

LicenseInsertCommand.py

import sublime, sublime_plugin

class LicenseInsertCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, 0, "License Text!")

I'm sure you could optimize it....

share|improve this answer

You could write your own plugin as above, and fire a call to the plugin on creation of a file, i.e. Class sublime_plugin.EventListener on_new(view)

http://www.sublimetext.com/docs/2/api_reference.html

hope that helps

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.