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
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:
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:
<binding key="ctrl+shift+f5" command="InsertDateAtTop"/>
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?