jEdit Snippets for Ruby on Rails 26
So, I don’t have a Mac yet (its on the way), so in the meantime, I use jEdit, the unsung hero of the non-Mac Rails programmer world. It’s a super fast, highly extensible editor. Having now read a few articles and installed some additional plugins, I found I can get most of the whiz-bang Textmate editor features, for free, on all platforms!
I thought I’d “give a little back to the community” and whip up some SuperAbbrev files for ruby and rhtml that mimic all of the Textmate Rails bundle snippets.
Note: This was totally inspired by Textmate and the syncPEOPLE Rails plugin for Textmate. So thanks to you guys for being awesome. I just thought I’d see how close I could get.
And why not, lets take it a little beyond the Textmate rails snippets, and throw in a few more that seem useful and obvious.
Basically, on the RHTML side, there is a TON of additional useful snippets.
Now this doesn’t include the other neat syncPeople commands, but if someone wants to help out with writing some jEdit macros, that would be dope.
So please, try it out, let me know if it works, add more snippets, etc.
Update: Matt Torok alerted me on the Rails mailing list that SuperAbbrevs only works with jEdit versions >=4.2final and <=4.3pre2. If you’re using the latest beta release, 4.3pre3, it’ll go wacky when you try to hit tab to switch between the fields.
What are snippets?
Snippets are small capsules of code that are activated by a key sequence followed by [CTRL-Enter]. For example, mct[CTRL-Enter] will activate the Migration Create Table snippet. The SuperAbbrevs plugin makes this possible.
Download:
Instructions:
- Install jEdit 4.2 if you haven’t already. (Note: Apparently SuperAbbrevs isn’t currently compatible with 4.3pre3)
- Install the SuperAbbrevs plugin (use the built in plug in manager to install it).
- Configure a keyboard shortcut for SuperAbbrevs expansion – mine is set to CTRL-Enter. Learn how to do this here.
- The files in the archive are SuperAbbrevs setting files. Extract them into {userhome}/.jedit/SuperAbbrevs/
On windows, that’ll be something like: C:\Documents and Settings\username\.jedit\SuperAbbrevs\
- Restart jEdit and go to Plugins > Plugin Options > SuperAbbrevs. Under the Abbrev Set dropdown, select either Ruby or Rhtml to get a list of all the shortcuts.
- The best way to learn these is to go through the reference guide (below) while running jEdit and just try each one out. You’ll catch on quick. The naming scheme is really simple and follows a pattern – first letter of each word. bt becomes belong_to, ho becomes has_one, ist becomes image_submit_tag, etc.
Documentation / Reference Guide
- Need a solution for RadRails? Voila: TextMate-like Template Syntax for RadRails
Here is my macros that allow to switch between model and controller http://community.jedit.org/node.php?id=2787
Vovan, thanks for the script, but no matter how hard I tried, I could not make it work :( It appears in my macros menu, but does nothing.
This is a great set of abbreviations! I’ve linked to this in my collection of jEdit related links in an article on jEdit and other RoR IDEs. Keep up the good work!
Thanks for sharing these wonderful snippets, i use em all the time.
I miss out a few ones in your list:
habtm: has_and_belongs_to_many
and for the rhtml part I miss the following snippets:
p:
li: s:tr: th:
Oh by the way, it’s really a shame to see all these spam comments, potentially burying valuable comments. We had the same problem on our blog, but try to keep it down as much as we can. Perhaps you are interested in http://justaddwater.dk/2006/06/28/blog-usability-avoid-spam-comments-part-2/
I know this is a bit late in the game, but this was very useful.
Thanks a lot.
I’ve extracted the ruby and rhtml into the appropriate directory, and I see them there, but how do I specify to use something other than “global” because they won’t work for me. Only what I have in globals. Thanks.
can somebody please write a few RoR snippets for VIM!?
http://files.myopera.com/mbbill/files/code_complete.gif http://www.vim.org/scripts/script.php?script_id=1764
is there actually a code beautifier for RHTML / RUBY in jedit ? i dont get it managed to beautify it .. thanks in advance !
I had written my own few snippets but dreaded having to input all of them. Are you planning to keep these updated?
Hi, I’ve hacked together a setup to load an RSpec backtrace into jEdit (in other words, you’ll be able to click the relevant failed behaviour or error to go straight the relevant file and line).
More info here: http://textgoeshere.org.uk/articles/2008/03/howto-integrate-rspec-on-rails-with-jedit/
Maybe of some use.
Dave
I had the same problem with the console of jEdit with input character for the scanf. Anyone know why?
Hey great post. This jEdit thing is really great. Alot better then gEdit.
Anyway, this post is old (now in 2008) and before the .html.erb style of templates. I’m wondering if there is an easy way to add the .rhtml abbreviations so that they work in .html.erb files without making them all global.
Thanks, kirk
Hey great post. This jEdit thing is really great. Alot better then gEdit.
Anyway, this post is old (now in 2008) and before the .html.erb style of templates. I’m wondering if there is an easy way to add the .rhtml abbreviations so that they work in .html.erb files without making them all global.
Thanks, kirk
I have a tutorial on how to use superabbrevs like snippets here: http://ifakedit.com/log/2006/02/19/jedit-tutorial-a-how-to-on-abbreviations-superabbrevs-in-html-ruby-on-rails-and-more/
I have a tutorial on how to use superabbrevs like snippets here: http://ifakedit.com/log/2006/02/19/jedit-tutorial-a-how-to-on-abbreviations-superabbrevs-in-html-ruby-on-rails-and-more/
These snippets are great. Thank you very much.
Sorry to see all this spam here, tho