Perspectives are task-related. Views are specific panels that can occur in any Perspective. A given Perspective comes preconfigured with some Views and a layout, but if you change that, Eclipse remembers what you had, and keeps it that way.
Selecting a given view and pressing Control-m will maximize that view. The other views are still available around the edges. Control-m again will reset it to the regular layout. Double-clicking on the tab of any view has the same effect.
Left clicking on any of the bars in the margin to the left of an editor provides options like "Show Line Numbers".
If you have Quick Assist turned on, there will be a lightbulb there to offer changes you might want to make (otherwise, Quick Assist is always available via Control-1 (that's a "one" not an "ell"))
When there are warnings or errors, the problematic code is underlined in yellow or red, and there is a marker in the left margin, and also a visible marker by the scrollbar on the right. You can jump to the problem spot immediately by clicking on the marker by the scroll bar. And all three will show you the error messags if you hover your mouse over them.
If Eclipse has suggestions on how you could potentially fix the problem, hovering over the code, or clicking on the marker to the left will give choices that are worth considering.
Eclipse offers two forms of auto-completion:
One is "Code Assist", which knows about Java, XML, or any number of other types of code you might be editing. "Control-SPACE" will do its best to offer you what it thinks makes sense in the code here. For example, type the first few characters of a variable name, and it will offer you the variables that start that way. If you're at the right side of an "=", it will offer you things that match the type that is required by the left side of that "=". It also supports "CamelCase" matches (for example, type
IEA and press Control-SPACE and it will offer you
The other is "Word Completion". "Alt-/" will simply cycle through the words it already sees in this editor that start with the same characters that you have already typed, starting with the closest ones. This is often all you need to retype a particularly verbose variable that you've just declared or manipulated, even if there's no code context for it to work with otherwise. It also works inside comments.
Control-TAB and Control-Shift-TAB as alternatives for flipping back and forth between editor tabs. I'm used to it from my browser.lets you configure keyboard shortcuts for all the commands Eclipse understands. I like to at least add
Control-/ comments/uncomments a line (or the entire selected area, if you have multiple lines selected)
Control-Shift-o (that's "oh", not "zero") will Organize Imports, which is a quick way of cleaning up the import statements at the top of the file that are no longer in use because you removed the code that needed them. It will also insert imports it needs as necessary. If you have red underlines because you pasted some code in from an outside editor, or because you typed the entier class name without autocompleting, then it will figure out what it needs (asking, if it has questions) and fill in the import statements as necessary.
Control-Shift-f auto-formats the entire file if nothing is selected, and only the selected area if something is selected.
Control-z and Control-y undo and redo as you are probably used to from plenty of other applications.
Control-f serves both Find and Replace via a dialog that pops up. Another helpful one for when you just want to skim through all occurrences of something, is to select and press Control-k. It takes you to the next occurrence of whatever text you have selected. It's not smart about specific types of code, but it's quick.
Control-Click on a variable, method name, or class name will take you to where that item is declared or defined.
There are some great "search" variations, like Control-Alt-h for Call Hierarchy. Helpful when you've got some method and you want a quick idea of how it could get called.
All of these keyboard shortcuts are available generally via context menu and top-of-the-app menu as well. I encourage you to explore context menus in particular, to see what you can do. Eclipse offers a lot of code smarts to help you along.
The Refactor items can be helpful, too. I use Rename a lot, since sometimes the first name I give a variable or a method really isn't ideal. It will rename the item and all of the code that refers to it. Note that it will not change anything inside comments, including code that's commented out.
There are an absolutely overwhelming variety of settings available in
Some of the ones I think are worth knowing about:
If you are working with someone else, or showing someone some code (or even projecting your code onto a screen somewhere), you may want to change the font size of your code. Go toThere are a lot of items to choose here, but the only one to worry about is since a lot of other ones use that by default. If you change the font size of just that one, you'll have achieved most of what you want.
One other area that might be worth changing for Android development is under
Editor section, we can change the formatting so that it's closer to what the Android sample code does, which makes it easier to visually track the extremely-long Android attributes.
Check the box next to Split multiple attributes each on a new line
Putting information in the "logcat" log is simple and very helpful.
Log.e("FAILED", "Something bad just happened here");
Note that if you type out
Log, you'll want to Organize Imports afterward, or you can use Code Assist (though typing
Lo and then pressing Control-SPACE go get the final
g really feels strange to me). Either way, it will ask you which Log you mean: You mean android.util.Log
Look in LogCat view to find the message (this one is an "ERROR" so it will be in red, and you can also filter on the first "tag", in this case "Example Message")
You can and should extract all repeated Strings into constants.
Select a string (including the double quotes on each side), then
It's also available as a Quick Assist (Control-1), and in the context menu.
Double-clicking in the left margin is a quick way of adding a breakpoint. If you start the application in debug mode, then code execution will stop each time it hits a breakpoint.
If you get to a point where you have a breakpoint in a tight loop and want to just move on, you can either disable the specific breakpoint, or just toggle the Skip All Breakpoints button in the Breakpoints View.
It's worth spending some time to understand the execution stack in the Debug View. Stepping into, over, and out of code can be an extremely good way of understanding what's really giong on in your code.
F5 (Step Into), F6 (Step Over), F7 (Step Return), and F8 (Resume) are a lot more convenient than clicking the little arrows, once you get used to it.
The Variables View is useful to examine the values of what's currently being executed. Debug makes you choose between it and the Breakpoints View by default. I always split them up so they're both visible.
FIXME can both be used in comments to mark areas that need attention. Eclipse will show them as blue marks in the margins.
Another View that can be used to keep track of them is the Tasks View.