New IntelliJ Tricks I Learnt Today
Join the DZone community and get the full member experience.Join For Free
day three of my brand new job - woohoo! one of my first tasks is checking the documentation of intellij, since i’m already a “power user”, to see if there’s stuff missing that someone like me might want to see. firstly, a confession - i’m not sure i’ve actually read the intellij documentation before. i mean, really read it. of course, i’ve dipped into it when i needed to know something, i’ve searched for help with specific items, but like many developers, i tend to use something first rather than read the documentation first.
but i’ll tell you what, today i’ve learnt a whole bunch of useful things intellij can do that i hadn’t previously known, and they’re the sorts of things you would only stumble over if a) you read the docs (pah!) or b) you watched someone else using the tool and saw them doing something you didn’t know was possible.
so here’s today’s list, and feel free to laugh at me and be smug in my direction if you already knew these things (note: i have upgraded to intellij 14, and at the time of writing i don’t know which of these features are new and which are simply previously undiscovered):
navigate directly to an action or option
press shift+ctrl+a (windows) or shift+cmd+a (mac) and start typing the name of the thing you want to do, or the setting you want to change. i’ve found this especially useful now i’m back on windows and i don’t have that nice helpful typing box on the help menu that will take me straight to the menu item i want. but what’s most useful about this for me today, as i’m setting up a new profile on a new laptop (more on the new laptop later, if it doesn’t defeat me utterly) is that from here, you can turn various settings on and off without having to navigate through the settings screen:
i never knew there was a shortcut for finishing off a statement , all that java boilerplate you need to keep the compiler happy - semi colons and curly brackets and everything. but there is, and i can see it being super useful, especially if you’re using other bits of intellij code completion to create the core of your line of code.
issue tracker integration
i’m sure loads of people are already using integration with their favourite issue tracker, but i hadn’t really thought about this as something that i really cared about. but i was watching the intro videos for youtrack (not surprisingly i’ll be using this instead of jira during my time at jetbrains) and when i saw how the ide integration worked , i suddenly realised how this small thing can add up to save thousands of keystrokes over time, not to mention saving precious navigational seconds and window-switching.
for me, just the ability to generate at least the start of the commit message is a saving in time, and adds to project consistency if all your developers are doing the same thing. on my last project we only just realised we all quoted the jira issues in subtly different ways.
settings shortcut keys
when i initially started using intellij in anger back in 2008, i was very much a point-and-click type user. over time, pair programming with keyboard-super-users and giving live demos with very limited time available, i’ve worked harder to become a keyboard-shortcuts person. with the latest version of intellij, i can’t find the tiny icons i use to get to the settings window, something that i’ve been using a lot as i set up the new ide instance on the new laptop. so i bit the bullet and learnt the keyboard shortcuts, and it’s already saving me a bunch of time (on the rare occasions when the aforementioned “navigate to action” fails me).
ctrl+alt+s for the settings dialog (appears to be cmd + , on the mac) shift+ctrl+alt+s for the project structure dialog (appears to be cmd + ; on the mac)
yeah. i can’t believe i wasn’t already using those either.
selecting the negative
i use completion/suggestions all the time from intellij, i’m far too lazy to type everything. what i didn’t realise, is that you don’t just have to accept the default they give you. if, for example, intellij suggests a boolean value, you can get it to negate that value by selecting it with “!” instead of enter or tab. yes, i know i’ve done a horrible job of explaining that, but take a look at the documentation and try it, it’s quite cool.
exclude from autocomplete
speaking of code completion, sometimes intellij is sometimes just a bit too keen to suggest something, and you really will never want that value. in the past, i’ve always used
settings -> editor -> general -> auto import
to manage the suggestions (the most common one for me is i will never want
, i will almost always want
). well, you don’t have to go into settings to do this, you can
do it from the suggestions themselves
- navigate to the item you don’t want (in my case,
) and press alt+enter, this will give you the option of excluding this from the suggestions in the future.
that’s what i found from just one day of browsing the documentation and setting up my ide from scratch yet again. maybe i’ll promptly forget all these, or maybe they’ll be new weapons in my armoury of ide-fu. either way, maybe one or two people will find this useful.
Published at DZone with permission of Trisha Gee, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.