I know people must have done this hundreds of times, but without instructions I just donāt get it. It would seem that a simple walkthrough for newbies is not too much to ask?
The whole point of this little exercise is to be able to write the current date in a file. In Notepad2 the shortcut is Ctrl+F5. Being just a teeny bit more ambitious, I wanted to have the date at the top of the file with the cursor in a blank line underneath - sort of a LOG file system. And my keyboard shortcut would be Ctrl+Shift+F5. So here goes:
Using the menu command āTools - New Pluginā I created a plugin and saved it under āC:\Documents and Settings\username\Application Data\Sublime Text\Packages\User\InsertDateAtTop.pyā. Hereās the code:
import sublime, sublimeplugin
from datetime import date
# This simple plugin will insert the current date/time at top of the buffer when run.
# To run it, save it within the User/ directory, then open the console (Ctrl+~),
# and type: view.runCommand('InsertDateAtTop')
#
# See http://www.sublimetext.com/docs/plugin-basics for more information
class InsertDateAtTop(sublimeplugin.TextCommand):
def run(self, view, args):
now = date.today()
view.insert(0, now.strftime("%Y.%m.%d %a %H:%M") + "\n\n")
view.runCommand("move line -1")
This is my first try at python, so thereās bound to be some bugs in it!
Anyway, I saved the file, and the console panel says:
So that sounds good.
Following the instructions in the HelloWorld sample, I opened the console and typed:
view.runCommand(āInsertDateAtTopā)
Nothing. No output. Now I assume if thereās an error in the code it would spit it out in the console. But the console is helpfully silent.
OK, thatās one issue. The other is setting up the keybinding.
The Plugin Examples page says:
This information is also very terse. It doesnāt say in **which ** āDefault.sublime-keymapā file to add the binding. It could be Packages/Default or Packages/User. I assumed since I put the code in the User folder, thatās where the keybinding would go. So I wrote this code there:
<bindings>
<binding key="ctrl+shift+f5" command="InsertDateAtTop"/>
</bindings>
You guessed it, nothing happens, no text in the console. I tried putting the binding in Packages/Default, same result.
What is wrong here? And why is a $60 product not being documented?
I donāt consider the āSupportā section to live up to that name. Everywhere on the site I see ādocumentation is in progress ;).ā Opensource projects for the most part are very lively with screenshots, tutorials and even screencasts. I guess they have to try harder.
Looking through the forum I saw one of you guys (āsublimatorā) is busy creating screencasts with camtasia. Kudos to you! Unfortunately I canāt make head or tails of what you are trying to say. Thereās no narration and the mouse and letters just rush all over the place. I tried installing the āPersistent Shellā package and type āls -lahā in a file, as seen in the screencast http://blogdata.akalias.net/console3/console3.htm. An excercise in futility. Mainly because I donāt know how sublimetext works!!
I know this post sounds ranty, but I *really * would like to use the product. It has the greatest interface on the market (Monokai!), and with just a little more effort with the docs people will be really happy and make you rich.
So pullease Jon, Nick et al. write a simple help file for people to get started, OK?
Oh yeah, whatās wrong with my code?