jEdit Snippets for Ruby on Rails 30

Posted by sbecker Mon, 20 Mar 2006 08:55:00 GMT

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:

  1. Install jEdit 4.2 if you haven’t already. (Note: Apparently SuperAbbrevs isn’t currently compatible with 4.3pre3)
  2. Install the SuperAbbrevs plugin (use the built in plug in manager to install it).
  3. Configure a keyboard shortcut for SuperAbbrevs expansion – mine is set to CTRL-Enter. Learn how to do this here.
  4. 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\

  5. 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.
  6. 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

Comments

Leave a response

  1. Avatar
    Michael Mon, 20 Mar 2006 20:38:43 GMT
    Thanks a lot, I just started using them and I already love them.
  2. Avatar
    Esad Tue, 21 Mar 2006 11:49:39 GMT
    Hi! What do you think about writing rails plugin for jedit? It could include support for generators, script/console and script/server etc. What do you think?
  3. Avatar
    scott Wed, 22 Mar 2006 00:38:10 GMT
    There's a Console plugin, so the easiest thing to do is just install that. Then you've got the console right there and can do all the script/generate and script/console stuff you want! What would be cool though is some keyboard shortcuts for easily jumping between a controller method and a view file, or a model, etc. I think Macros could accomplish this but I haven't delved into it.
  4. Avatar
    Sune Simonsen Sat, 25 Mar 2006 00:15:05 GMT
    I'm the author of the SuperAbbrevs plugin for jedit, if you are interested in testing the beta version (Pretty stable but misses some documentation), send me a mail, and I will send you the improved plugin. I have a working version for 4.3pre3 aswell, if you want to ride on the edge :-)
  5. Avatar
    Istvan Tue, 11 Apr 2006 08:31:22 GMT
    This snippet collection is great. I had written my own few snippets but dreaded having to input all of them. Are you planning to keep these updated? If so, it would be great if you had an RSS feed for that.
  6. Avatar
    Alistair Sat, 15 Apr 2006 21:41:54 GMT
    I was just introduced to jEdit at the Canada on Rails conference and I love it. These snippets make it even better - thanks! Suggestion: I know zero Java, but I'd like to see a plugin similar to the RubyDocs (that can be docked as a sidebar) has two panes: top pane containing the libraries (Such as Ruby, Rails or HTML), bottom pane contains: shortcuts belonging to the selected library with short descriptions for each snippet. Anyone know enough Java to do this?
  7. Avatar
    Scott Becker Fri, 21 Apr 2006 00:36:00 GMT
    What it sounds like you're talking about (searchable Ruby Docs in jEdit) already exists - have you looked at http://rubyjedit.org/ ? It's a must if you're building RoR apps in jEdit.
  8. Avatar
    Seth Thomas Rasmussen Sat, 22 Apr 2006 20:54:54 GMT
    Wicked pissa, man.. muchos gracias.
  9. Avatar
    Sune Simonsen Sat, 29 Apr 2006 12:07:31 GMT
    The beta release of SuperAbbrevs can be found here: http://community.jedit.org/?q=node/view/2761 http://community.jedit.org/?q=node/view/2762
  10. Avatar
    Tammy Cravit Thu, 11 May 2006 16:10:24 GMT
    Thanks for posting these. I've added a couple of other abbrevs to my list that might be useful for people: habtm - has_and_belongs_to_many :${1:object}, :class_name = "${2:ClassName}"$end hmt - has_many :${1:objects}, :through = :${2:RelatedObjects}$end
  11. Avatar
    Vovan Fri, 19 May 2006 18:34:25 GMT

    Here is my macros that allow to switch between model and controller http://community.jedit.org/node.php?id=2787

  12. Avatar
    Copernic Fri, 26 May 2006 18:05:44 GMT

    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.

  13. Avatar
    Kaleb Walton Sun, 30 Jul 2006 14:02:38 GMT

    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!

  14. Avatar
    Jesper Rønn-Jensen (justaddwater.dk) Wed, 30 Aug 2006 07:08:07 GMT

    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:
  15. 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/

  • Avatar
    ashley graham Sat, 11 Nov 2006 01:24:16 GMT

    I know this is a bit late in the game, but this was very useful.

    Thanks a lot.

  • Avatar
    ryan Sat, 09 Dec 2006 17:26:34 GMT

    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.

  • Avatar
    jona Thu, 15 Mar 2007 04:14:51 GMT
  • Avatar
    testrails Tue, 01 May 2007 11:18:47 GMT

    is there actually a code beautifier for RHTML / RUBY in jedit ? i dont get it managed to beautify it .. thanks in advance !

  • Avatar
    程控交换机 Fri, 11 May 2007 05:43:49 GMT

    I had written my own few snippets but dreaded having to input all of them. Are you planning to keep these updated?

  • Avatar
    Mark Ipkins Thu, 13 Sep 2007 11:55:33 GMT

    Hello, i like cars! Want to have some friends!

  • Avatar
    http:/www.portraitkingdom.com Tue, 30 Oct 2007 04:48:13 GMT

    Here’s the latest problem I’ve had with jEdit. Why is it that in the console of jEdit upon running the program the system asked me FIRST the input character for the scanf. Only after that will it print out “write something”?

    But when I try to run the same program under a normal shell of linux everything is correct.

  • Avatar
    http:/www.portraitkingdom.com Tue, 30 Oct 2007 04:48:19 GMT

    Here’s the latest problem I’ve had with jEdit. Why is it that in the console of jEdit upon running the program the system asked me FIRST the input character for the scanf. Only after that will it print out “write something”?

    But when I try to run the same program under a normal shell of linux everything is correct.

  • Avatar
    http:/www.portraitkingdom.com Tue, 30 Oct 2007 04:48:22 GMT

    Here’s the latest problem I’ve had with jEdit. Why is it that in the console of jEdit upon running the program the system asked me FIRST the input character for the scanf. Only after that will it print out “write something”?

    But when I try to run the same program under a normal shell of linux everything is correct.

  • Avatar
    http:/www.portraitkingdom.com Tue, 30 Oct 2007 04:48:25 GMT

    Here’s the latest problem I’ve had with jEdit. Why is it that in the console of jEdit upon running the program the system asked me FIRST the input character for the scanf. Only after that will it print out “write something”?

    But when I try to run the same program under a normal shell of linux everything is correct.

  • Avatar
    family portrait artist Tue, 30 Oct 2007 04:48:55 GMT

    Here’s the latest problem I’ve had with jEdit. Why is it that in the console of jEdit upon running the program the system asked me FIRST the input character for the scanf. Only after that will it print out “write something”?

    But when I try to run the same program under a normal shell of linux everything is correct.

  • Avatar
    family portrait artist Tue, 30 Oct 2007 04:48:59 GMT

    Here’s the latest problem I’ve had with jEdit. Why is it that in the console of jEdit upon running the program the system asked me FIRST the input character for the scanf. Only after that will it print out “write something”?

    But when I try to run the same program under a normal shell of linux everything is correct.

  • internet forex trading Tue, 06 Nov 2007 18:01:12 GMT

    It’s comparative to be closed! Ah, some rear patient concisely wore circa that ill level. That subject has the vital internet forex trading market. That costly area paid opposite to a friendly internet currency trading. Obviously, one grand world sensationally whimpered amidst the bitter amount. Umm, the ugly internet forex trading diversely gloated for some satisfactory way. Embarrassed plan is some angry sort. By the way, some wall is much less prepared than one mean minute…

  • jouer roulette en ligne Mon, 12 Nov 2007 12:18:16 GMT

    It’s continuous to be pre-set! I swung that jeux close to the student. Night fed this club. Well, one boy is more constitutional than this exact en ligne. The orthodox land had this jouer emotionally. I curtsied that jouer without some en ligne. This complete jeux fidgeted opposite to one victorian house. That wrong jouer hummed a month incredibly…

  • jugar backgammon Sat, 17 Nov 2007 12:27:39 GMT

    One manager has a false class. One unusual staff rode considering a statutory child. Some spatial jugar swung this site forgetfully. A backgammon has that definite stage. Poor health is a distinct parent. The stable worker hooted one job cannily. Obviously, one backgammon is less broad than this ethnic meeting. Head backgammon is some interior face…

  • Avatar
    Dave Nolan Sat, 29 Mar 2008 09:05:30 GMT

    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

  • Comments