jEdit Snippets for Ruby on Rails 30
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?
Hello, i like cars! Want to have some friends!
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.
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.
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.
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.
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.
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.
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…
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…
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…
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