I don’t know if this is true, but I imagine that the Eclipse user-base is exploding due to the advent of PhoneGap and Mobile Application frameworks like Sencha Touch and JQuery. I’ll go a step further and assume that a significant portion of HTML 5 Mobile App Developers are coming over from the front-end web development world since these new technologies have dropped the entry curve considerably to mobile app development.
So, a lot of new Eclipse users in a new IDE means… (drumroll)… a lot of questions. So in my short time in using Eclipse I’ve come across a handlful of things that I find myself using/doing all of the time that saves time. I thought I’d share these “tips” as you might find them useful as well.
This is a very handy feature. I find myself starting Sencha Touch projects by first building out the “skeleton” – all the panels, nested panels (the parents of which I personally call “card decks”, as most child panels have the “card” layout), setting up listeners, creating empty functions knowing that I will need to flesh them out at a later date, etc. And so while doing this I need a handy way of indicating that there is something to do in that particular location in my code. Eclipse has a nice visual que for this called “TODO’s” that when used appear in a thin vertical strip next to the vertical scrollbar. This strip is called the “Overview Ruler”. To add a TODO to your project simply create a comment and put the “TODO” text after it (i.e., “/* TODO */” and Eclipse will display a blue marker in the Overview Ruler. Feel free to expound on what needs to be done within your comment as well.
Eclipse also does something that I think is annoying and that interferes with the “TODO” feature – it displays a yellow marker in the same vertical area as it does the blue “TODO” markers for things like variables that it thinks arent used or for lines that might be missing a semi-colon (which often are not). All this clutter will hide your “TODO” markers. To turn off the yellow markers do the following:
Right click the Overview Ruler and choose “Preferences”:
Next click “Annotations”, then scroll down to the “Warnings” Annotation Type. Click “Warnings” and then deselect “Overview ruler”. Click Apply/Ok and your done.
Wildcard Searches with CTRL+F
Find/Replace is not so much of a tip as we’re all familiar with it. But, if you are like me and have a long history using Dreamweaver you may have learned how to take advantage of regular expressions in your search/replace activities. No worries, this little tip is simple – you can do wild card searches in your projects by using an asterisk (*) – as long as you check the “Regular Expressions” check box. This is especially useful if you employ naming conventions for variable and function names.
For example, if you know that you are looking for an ID but don’t recall the entire string, but know that due to your naming conventions that it starts with “txn” and its a “sheet” (a Sencha Touch-specific feature) you would search for all occurances of it by entering “txn*sheet” and then hit the Find button until you find what you’re looking for.
Jump to Last Edit with CTRL+Q
I use this more than anything else – simply jump back to your last edit point from anywhere in your code by pressing CTRL+Q.
Go to line using CTRL+L
Not much to say here – when I debug using Chrome with the developer tools turned on I can see where errors and my console.log statements appear within my code. Just look at Chrome’s console, note the line number, then zip straight to the line in Eclipse.
LogCat is where all your console.log statements appear within Eclipse – as well as a million other things happening on your phone or tablet. So much stuff shows up that the one thing that you’re interested in often just scrolls out of view. You can filter the LogCat window by typing in an expression where Eclipse indicates as much:
The easiest thing to do is to simply follow Eclipse’s direction and type the Prefix of what you are looking for and enough characters to get what you want. In our case, what we want is the Web Console. But thats two words with a space in between which won’t work (as you will discover). We can do something as simple as just “tag:web” which narrows down the list greatly:
Thats better – but not perfect. We see everything with the word “web” in its Tag, but all we want is the “Web Console”. To get there we need to write a Java regular expression – the entire string would be: “tag:^web\sconsole$”, as shown below:
And, if you are lazy, you can save your regular expression for later use by toggeling the Saved Filters View button illustrated to open the Saved Filters pane:
At this point, click the “Plus” icon and fill in the desired fields. Whenever you want to filter the log you can just click the Saved Filter View button to reveal your saved filters and select the filter that you want to apply.
Eclipse runs better with more memory, and what doesn’t? Thing is you might have 8 or 16GB or more in your dev machine but that doesn’t mean Eclipse is using it. The memory it uses is defined in the eclipse.ini file. If you get out-of-memory errors and the like you need to allocate more RAM to Eclipse.
On a standard Windows install, you will need to edit the ini file which is located in the root of your Eclipse install directory. This is a topic that others have expounded on better than I ever could so I’ll leave you with a link to a particularly good post on the topic:
Read more here: http://blog.xam.dk/?p=58.