Photo from Chile

Getting Code Assistance in Eclipse when Creating ValidateThis XML Files

Although ValidateThis, my validation framework for ColdFusion objects, can accept metadata in a number of formats, my preferred method is via an XML file. This file defines all of the validation rules for a particular object, and can, obviously, be created using any text editor. If, like me, you are using Eclipse as your IDE (which includes users of ColdFusion Builder), you can enable code assist thanks to the XML Schema Definition (XSD) that I created for ValidateThis. This post will describe how to enable that feature.

What is an XSD?

XSD stands for XML Schema Definition. It is the successor to the Document Type Definition (DTD), providing a description of the required structure of a particular type of XML document. XSDs are themselves written in XML, which makes them both machine- and human-readable. They are therefore an excellent source of documentation about the type of XML document that they describe, and they can also be used to validate an XML document and to enable code assist when editing an XML document.

[More]

Creating Eclipse (and CFBuilder) Keyboard Shortcuts for Subclipse

Here's another quick tip to keep your hands on the keyboard and off of the mouse. I currently use both Subversion and Git for version control of my code, but I definitely use Subversion more. One thing that I found myself using the mouse for time and again was to commit changes to my SVN repo using the Subclipse Eclipse plug-in. One of the worst things about that workflow is the number of steps it takes. You have to right-click, then select Team, and then select Commit from the menu. I'm not sure why I continued to do that for so long, but I finally got around to Googling "Subversion Keyboard Shortcuts" and came across a blog post by Mads Darø Kristensen, with a video no less, that shows exactly how to set these up. The steps are as simple as this:

  1. Open the Eclipse Preferences menu (command+, on a Mac).
  2. Choose General -> Keys.
  3. In the box where it says type filter text, type SVN.
  4. Choose the Commit command from the list of commands.
  5. Place your cursor in the box labelled Binding and type the key combination you wish to use. I use control+option+C.
  6. Click the Apply button.

Now, when you're done editing a file and you want to commit it to your SVN repo, just type the key combination and the Subclipse Commit dialog box will appear. If you want to commit all files in a project or a folder, rather than just the current file, then highlight the project or folder (which seems to require some mouse-work, unfortunately), and then type your combo. I've also assigned control+option+R to Revert and control+option+S to Synchonize with Repository. I'm finding that these shortcuts are saving me a lot of time, and allowing me to keep my hands on the keyboard, where they belong.

Three Eclipse (and CFBuilder) Shortcuts to Improve Your Life

OK folks, this is a big deal. I'm going to tell you about three keyboard shortcuts that you really need to incorporate into your routine. These are nothing new. Marc Esher blogged about these nearly a year ago, and there's a good chance that you're already using them, and if so, you know how amazing they are. But if you're not using them then you're really missing out.

If you're like me at first glance they won't seem like a big deal. You'll think, "How often do I need to do that?" But if you get yourself into the habit of using them, you won't believe how much more pleasant your time spent coding in Eclipse will be. Enough of the sales pitch, let's get on with it. The three shortcuts are:

  • Command+Option+Up/Down (Ctrl+Alt+Up/Down on a PC) - copy the selected line(s) above or below themselves
  • Option+Up/Down (Alt+Up/Down on a PC) - move the selected line(s) up or down
  • Command+D (Ctrl+D on a PC) - delete the selected line(s)

These commands blow cut/copy and paste out of the water. One of the best things about them is that you don't have to select an entire line to use them. Your cursor can be anywhere on the line(s) and it will work, so you don't have to bother hitting the Home key to move to the beginning of a line to copy, move or delete it. If this still doesn't seem like not a big deal to you, let's walk through a quick exercise. Take the following code and copy it into a file in Eclipse:

view plain print about
1<cfif something>
2    do something
3    that takes 2 lines of code
4<cfelseif somethingElse>
5    do something else
6    that takes 2 lines of code
7</cfif>
8
9<cfif anotherTest>
10    do something different again
11    that takes 2 lines of code
12<cfelse>
13    do something completely different
14    that takes 2 lines of code
15</cfif>

Let's say we want to add a similar cfelseif block into the second cfif block. Put your cursor anywhere on the existing cfelseif tag line and do shift+down x 2. You should now have part of the cfelseif line highlighted as well as all of the next line and part of the following line. Now do ctrl+alt+down. Your three lines of code have been duplicated immediately below the previously selected lines, and now they are selected. Now do alt+down x 5. Voila, you've copied your cfelseif block right where you needed it in very few keystrokes, and only had to lift your fingers from the keyboard once. Try that with copy and paste!

If you're still not with me on this one then I humbly suggest that you try doing it for a few days (or even just a few hours). Try to force yourself to use these shortcuts anytime that you need to copy, move or delete a line or block of code. I'm willing to bet you'll be hooked in very short order.

If you're wondering why I choose to blog about these now, I was inspired by a colleague. I only started using these shortcuts a few weeks ago and was kicking myself that I hadn't picked them up sooner. I was chatting with my friend and, somewhat , admitted that I had only started using them recently. "What do they do?" he asked. I was shocked that he too was not benefitting from their incredible usefulness, so I figured I should write this up to share this tidbit with everyone. Enjoy!