3 ms·
It would be really nice if there was a way to configure a key command in ST2 to run a specific script depending on the language you're writing. I don't usually
by mercuryrising 14y ago
It would be really nice if there was a way to configure a key command in ST2 to run a specific script depending on the language you're writing.
I don't usually write C unless I'm writing stuff for Arduinos. The Arduino IDE isn't very nice, but they have the magical commands "Control+U" and "Control+Shift+U" that upload code either through the FTDI board or a programmer. If I had that in ST2, I would be in heaven (right now I write in ST2, copy, paste into Arduino IDE, then upload).
- bpatrianakos 14y agoWrite a plugin for yourself complete with the key bindings you want. ST2 plugins are just Python scripts. Granted you have to know Python but I assume since you're writing C and mesing with Arduino you either already know it or can pick it up with no problem.
- CJefferson 14y agoWhile I know they are in python, I have never been able to find any documentation about how to build plugins, and what they can do. Could you point me to such a thing?
- bpatrianakos 14y agoYeah, definitely! Here are the two I used - fair warning, one is a Nettuts article. It's not the best tutorial ever but I had never written any Python before reading it and I was able to pull out the useful bits and apply them to my own plugin. http://net.tutsplus.com/tutorials/python-tutorials/how-to-create-a-sublime-text-2-plugin/ http://net.tutsplus.com/tutorials/python-tutorials/how-to-cr... - If nothing else, this will at least teach you how a Sublime plugin works (like where it lives and how you add it to the editor and such) After that, the Sublime API will take it from there - http://www.sublimetext.com/docs/2/api_reference.html http://www.sublimetext.com/docs/2/api_reference.html I took bits about how ST2 plugins are structured from the first article, then looked for 'how to do X n Sublime' in the second and once I got those down it was just a matter of Googling for "how to do Y in Python". The basic gist of it is that a plugin for Sublime is just a Python script that lives in Sublime's packages directory (~/Library/Application Support/Sublime Text 2/Packages on a Mac). Create a folder named after your plugin, drop the python script in there, and then use Python + the Sublime API methods to interact with the browser.
- castles 14y agoYou can set a `context` on key bindings to trigger only in specific language scopes or per project by referencing the `settings` key in the sublime-project file. In fact, you can even write a python plugin to create your own contexts that you declare in the sublime-keymap json. Check out G's docs: https://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/key_bindings.html https://sublime-text-unofficial-documentation.readthedocs.or...
- guavaroo 14y agoYou can select "Use external editor" in Arduino preferences, this will save you the copy and paste. Once done editing in SublimeText you just tab over to the Arduino IDE and "CMD+U" to upload.
- tomhenderson 14y agoIf you can do it from a terminal you should be able to add a build command and run the script with cmd+B. This site has a pretty good run down of how they work: http://addyosmani.com/blog/custom-sublime-text-build-systems-for-popular-tools-and-languages/ http://addyosmani.com/blog/custom-sublime-text-build-systems...