Alright it can be a lame question, but everybody uses these things differently. What's some of the best time savers out there for this IDE.
Tom
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Type 'syso' then press Ctrl+Space to expand it to System.out.println().
Tres handy.
Hippie expand/Word Complete, afaik inspired by Emacs: will autocomplete any word in any editor based on other words in that file. Autocomplete inside String literals in Java code, in xml files, everywhere.
Alt + /
Alt + Shift + R to refactor and rename.
Don't forget Ctrl+Shift+L, which displays a list of all the keyboard shortcut combinations (just in case you forget any of those listed here).
Alt-Up Arrow moves the current selection up a line, Alt-Down Arrow moves it down. I also use Alt-Shift-Up/Down Arrow all the time. Ctrl-K and Ctrl-Shift-K is quite handy, finding next/previous occurrence of the current selection (or the last Find, if nothing is selected).
Ctrl-2 something
Seems that nobody mentioned Ctrl-2 L (assign to new local variable) and Ctrl-2 F (assign to a new field), these ones have changed how I write code.
Previously, I was typing, say (| is cursor location):
and then I pushed Ctrl-Space to complete the constructor call. Now I type:
and press Ctrl-2 L, which results in:
This really speeds things up. (Ctrl-2 F does the same, but assigns to a new field rather than a new variable.)
Another good shortcut is Ctrl-2 R: rename in file. It is much faster than rename refactoring (Alt-Shift-R) when renaming things like local variables.
Actually I went to Keys customization preference page and assigned all sorts of additional quick fixes to Ctrl-2-something. For example I now press Ctrl-2 J to split/join variable declaration, Ctrl-2 C to extract an inner class into top-level, Ctrl-2 T to add throws declaration to the function, etc. There are tons of assignable quick fixes, go pick your favourite ones and assign them to Ctrl-2 shortcuts.
Templates
Another favourite of mine in my “npe” template, defined as:
This allows me to quickly add null argument checks at the start of every function (especially ones that merely save the argument into a field or add it into a collection, especially constructors), which is great for detecting bugs early.
See more useful templates at www.tarantsov.com/eclipse/templates/. I won't list them all here because there are many, and because I often add new ones.
Completion
A few code completion tricks:
Assign To A New Field
This is how I add fields.
If you have no constructors yet, add one. (Ctrl-Space anywhere in a class declaration, pick the first proposal.)
Add an argument (| is cursor position):
Press Ctrl-1, choose “assign to a new field”. You get:
Add a null-pointer check if appropriate (see “npe” template above):
Hit Ctrl-Space, get:
A great time saver!