Teaching an Old Dawg New Tricks 33
I learned something a few weeks ago that has saved me quite a bit of typing. I’m a pretty good typist but I still feel that saving a few seconds here and there pays compound interest when integrated over weeks, months, and a career. I’ve never seen anyone do this before and I get to work with a lot of programmers so I thought I’d share it here.
Joe “J.B.” Rainsberger was in our office a few weeks ago giving some internal training. Joe is the author of JUnit Recipes and if you don’t already own the book, buy two copies – it’s very good. Anyway, Joe was doing a demo for us and I watched how he created objects in Eclipse. If I wanted a new Counter object, for example, I would type:
Counter counter = new Counter();
But Joe would type:
new Counter();
and he then uses Eclipse’s Quick Help (ctrl-1) which offers to either create a local variable or a field in the class. That’s 2 keystrokes if Eclipse does it or 15 if I type it. That’s quite a return on investment in my book.
Try it and see if it makes you go just a little bit faster.

ctrl-1 (cmd-1 on mac) offers many, many cool shortcuts. Some are geared towards solving compilation problems like the one you desribe above. Others are simply helpful tasks like assigning the value of a parameter argument to a newly created field (it creates the assignment and the field simultaneously).
Definitely, Ctrl+1 is probably the most used shortcut key in my eclipse arsenal (well except maybe Ctrl+F11 to re-run the tests).
IntelliJ IDEA makes this even easier, since you don’t have to type the ; before the refactoring. So you can just type “new Co” (ctrl-space) (enter) (ctrl-alt-v) (enter). This is possibly my most used key combination of that length. Looking at it now it could probably be simplified.
alternatively, in Eclipse, you could do the following:
1) type “Count” 2) hit ctrl-space for code completion; chances are Counter will be the top entry. 3) type “counter = new” 4) hit ctrl-space for code completion; Counter will be the top of the list.
You have to hit a few more keystrokes to do the code completion, but that’s balanced by fewer keystrokes for the classname. More important (to me), you’re moving forward, adding to the line of code, rather than stopping and filling in.
In this particular case. I’d type “new” followed by ctrl-space. Which invokes the pre-defined “new-template”. There are a few more useful ‘macros’ I like. All as easily invoked as the one above:
- foreach
- main
- for
I can also recommend creating you own. Window – Preferences – Java – Editor – Templates
Me and a few friends usually jokes about this and referring to it as ctrl-space/ctrl-1 programming ;-)
Even better in Eclipse: some of the most-used Quick Fixes have their own hotkey. Instead of Ctrl+1, try Ctrl+2, followed by L for local variable or F for field. This is how I routinely do it now.
Take care.
Alt Shift L for local field. Alt Shift M for Extract Method. (Alt Shift I for Inline if you Extract Method too far)
That and things like showing the class hierarchy, showing the implementation hierarchy of the selected method, highlighting usage of whatever your cursor is on in different colours for read and write, call hierarchy both incoming and outgoing. All very handy shortcuts.
I’m stuck with Visual Studio at the moment which, even with Resharper, doesn’t come close to the tools available in Eclipse!
it is really good ,you can have a try
Do you have many new tricks?
How to convert AVI to iPad with best iPad Video Converter – AVI to iPad Best AVI to iPad Converter a professional iPad converter to convert avi files into iPad mp4 format, of course it can easily convert almost 100 kinds of videos to iPad for enjoying. The input format includes AVI, AMV, MKV, FLV, MTS, M2TS, MOD, H.264/AVC, RMVB, HD TS, HD MOV, WMV HD, etc. Best AVI to iPad Converter allows users to enjoy videos with the large and high-resolution screen freely with your iPad. There are many powerful editing functions such as effect, trim, crop, add watermark, merge and so on. RECOMMENDED: For Mac Users, you can try iPad Converter for Mac Version! FLV to iPad Converter DivX to iPad Converter
Thank you that you can take your time from your busy scheduel, it is very kind of you to provide this precious information for us There is certainly certainly a great dvd ripper for mac deal to understand about this. I imagine mac dvd ripper you built some great points dvd ripper mac in Functions also. Preserve doing work ,great employment!
Your site is amazing.I am very impressed to see this,i want to come back for visiting your site.Keep doing Good as well as you can.
great post and like it
Thomas sabo developed its own distinctive way, a distinguishing face due to constant support and designs by both of them. They had an eye for detail, an amazing compassion for the material and a sixth sense for thomas sabo charms fashions and trends. A complete new segment was created for the market because of this. Looking at the amazing success achieved, by the end of 1990 his company determined to establish retail outlets of thomas sabo its own. Throughout Asia, Europe and America exclusive stores, sales agencies and shops were set in different countries in rapid succession. Thomas Sabo changed from being a secretive protection of fashion insiders to getting developed as a well-built, globally acknowledged brand. The most popular collection of thomas sabo jewellery Charm Club Collection was originated with the creative director Susanne Kolbli’s idea. Today fashion has more freedom than ever before. There are diverse trends all over and so is their collection.
Definitely, Ctrl+1 is probably the most used shortcut key in my eclipse arsenal.
I’ve read an article with Eclipse hotkeys and it was also a list. This can help beginners to become experienced Eclipse user faster.
Great sources for fashion news and fashion articles. It’s got offered many details around the relevant information. I like this post a lot and i am likely to recommend it to my buddies. Brief and practical methods within the post saving time and inside searching process. It’s this kind of awesome source or technique i can’t wait to attempt it. The post is utterly incredible. Appreciate your all you could posted and whatever you present to us!
I like what you have said,it is really helpful to me,thanks!
This very useful counter. Thanks …
nice sharing.thanks my dear friend and i will come next time.
Do you like the Red Pumps? They are very popular in the young friends, because they have different styles. We are Red Heels and Red Shoes providers. We can give you the cheapest price and the best service, and do you want to join us at once?
Thank U for sharing.It helps me a lot.
Mulberry Outlet Syles from the new collections at reduced introductory prices. This is a great way to pick up a trendy, new but cheap designer Mulberry Outlet handbag.
great article ,thanks
Say thanks a lot for your time best rolex watches and energy to have put these things together on this weblog. Jack and i also very much loved your knowledge through your own articles wrist watches for men in certain things. I’m sure that you have several demands on your schedule hence the fact that you took just as much time as you did to steer people really like us through this article is definitely highly liked breitling bentley watch.
The proposals, which have not been Gas RC Car fleshed out and only show up as broadly worded titles so far, They do not consist of nicely more Off-Road RC Car than 100 bills that have been thought to be earlier this yr that lawmakers agreed to hold more than to 2012, The desire record of lawmakers’ 1:5 Scale RC Car proposals to become thought to be by council on Monday is intended to become restricted to “emergency” measures,
A suggestion to prohibit union RC Monster Truck people from spending union dues via authorized payroll deductions has currently produced opposition from well prepared labor,
This is a really good post. Must admit that you are amongst the best bloggers I have read.Monster beats studio Ferrari Headphones Monster Beats headphones E-shop Thanks for posting this informative article.
Our main products have various series, such as FESTO cylinder,oil lubricator,two-way solenoid valve,double acting cylinder,hand pull valve,quick exhaust valve,pneumatic cylinder,hand operated valve,SMC cylinder,cylinder piston rod and pneumatic solenoid valve for sale. Our pneumatics are widely used in different industries.
Users are complain about the data lose on the tablet. why not backup to Mac before lose them? yeah! a regularly backup of the file can be a good idea!
This article is a wealth of interesting quality content. Your thoughts are well-written and researched. I relate to this information. Thank you for providing this information to readers who like to think outside the box.
This is a great piece of writing! I am highly impressed with your research and writing skills. You have hit the nail right on the head with this information in my opinion. You are wonderful.
Every year we take the family to somewhere special to get away and just enjoy life. Our family doesnt like to stay in hotels all the time so we decided to start renting condos and timeshares, this was one of the best ideas ever.