{"id":466,"date":"2012-03-13T21:22:11","date_gmt":"2012-03-13T20:22:11","guid":{"rendered":"http:\/\/www.nobugs.org\/blog\/?p=466"},"modified":"2012-03-13T21:58:41","modified_gmt":"2012-03-13T20:58:41","slug":"eclipse-ing","status":"publish","type":"post","link":"https:\/\/www.nobugs.org\/blog\/archives\/2012\/03\/13\/eclipse-ing\/","title":{"rendered":"Eclipse-ing"},"content":{"rendered":"<p>Thought I&#8217;d share my favourite eclipse tips, since I&#8217;ve been living in eclipse recently.  I first used eclipse in 2003 on a laptop with a shoddy trackpad, and I think that lead me into a mouse-free habit.<\/p>\n<p>Navigation around text:<br \/>\n1. ctrl-. and ctrl-, to jump to next\/last compile error.<br \/>\n2. ctrl-shift-p to bounce between matching parens.<br \/>\n3. Expand\/contract selection syntactically &#8211; alt+shift+up\/down.  Replaces 90% of all careful mouse-drag selecting.<br \/>\n4. Move cursor using incremental search (ctrl-j) rather than cursor keys.<br \/>\n5. See all uses of a field\/variable quickly &#8211; bind &#8220;search all occurances in file&#8221; to a key (I used alt-shift-f), put cursor on a field, hit your shortcut, then use ctrl-. and ctrl-, to jump between occurances.<br \/>\n6. Move lines of code around with alt-{up,down}<\/p>\n<p>Navigation around projects:<br \/>\n1. Switch to recently used editors\/view\/perspective &#8211; ctrl-{f6,f7,f8}.  I also bind the f6 action to ctrl-tab too.<br \/>\n2. Most laptops have a &#8220;right-mouse-click&#8221; key on the keyboard.<br \/>\n3. &#8220;alt-shift-q p&#8221; to focus on the package explorer, shift-{left,right} to expand\/collapse folders, then f12 to focus back on the editor.<br \/>\n4. Use &#8216;show call hierarchy&#8217; (ctrl-alt-h) and &#8216;show in type hierarchy&#8217; (f4) lots rather than dumb search.<\/p>\n<p>Type less stuff:<br \/>\n1. Create new variables by just typing &#8220;new Foo();&#8221; and then &#8220;ctrl-2 l&#8221; to assign to a local.<br \/>\n2. In the outline view, drag methods to reorder them in the file.<br \/>\n3. Use templates to surround stuff &#8211; saves hunting for the correct location for a closing bracket.  Create a template called &#8220;validate&#8221; with &#8220;Validate.notNull(${word_selection})&#8221;.  Then use it by selecting an expression (using expand-syntactically), hit ctrl-space twice to see templates and pick your new template.  Eclipse wraps the existing expression with the template!  Or, do a more generic version, such as &#8220;${cursor}(${word_selection})&#8221; which sets you up to pass the selected expression as an argument to a method call.<\/p>\n<p>Random:<br \/>\n1. Ctrl-shift-L twice takes you straight to the keybinding pref.<br \/>\n2. When changing existing code, try to only ever use refactorings &#8211; avoid editing at the raw textual level.<br \/>\n3. I also do a lot of speculative refactorings, most of which I immediately undo.  For example, if I see a big method, I&#8217;ll select some likely looking chunk and try an &#8216;extract method&#8217;.  If eclipse tells me it&#8217;ll need too many parameters, I&#8217;ll cancel and try a bigger\/smaller chunk of code.  Or, if one of the parameters looks odd to me, I look to see if I can reorder code, or extract a new local, prior to running extract method.  I call the new method &#8216;foo&#8217; until I decide if it&#8217;s a keeper or not.<br \/>\n4. Use the quickfixes for the if\/when\/switch keywords (eg. &#8220;invert if, convert to continue&#8221;)<br \/>\n5. Use ctrl-m to toggle maximize your view\/editor.<br \/>\n6. Use the <a href=\"http:\/\/code.google.com\/p\/eclipse-fullscreen\/\">eclipse-fullscreen<\/a> extension (ctrl-alt-z) for even more screen space.<\/p>\n<p>Running stuff:<br \/>\n1. Go to prefs, search for &#8220;launching&#8221; and tick &#8220;always launch the last-run application&#8221;.  Then use f11 and ctrl-f11 to run whatever tests\/app you&#8217;re working on.<\/p>\n<p>I also have an eclipse extension that I wrote to toggle between a class and its test class.  I&#8217;m still squishing bugs in it, but I&#8217;ll share it if you&#8217;re interested.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thought I&#8217;d share my favourite eclipse tips, since I&#8217;ve been living in eclipse recently. I first used eclipse in 2003 on a laptop with a shoddy trackpad, and I think that lead me into a mouse-free habit. Navigation around text: 1. ctrl-. and ctrl-, to jump to next\/last compile error. 2. ctrl-shift-p to bounce between [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-466","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/comments?post=466"}],"version-history":[{"count":4,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/466\/revisions"}],"predecessor-version":[{"id":470,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/466\/revisions\/470"}],"wp:attachment":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/media?parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/categories?post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/tags?post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}