We at b-nova use JetBrains IntellJ on a daily basis as our preferred IDE. It is not only us, but IntellJ is highly successful as it proposes lots of quality-of-life features that make coding fun again. Over time, the editors eco-system got expanded tremendously. It reached a wealth of features that by now most --us at b-nova included-- don't know anymore what IntellJ has to offer. As such, we fought that we're going to compile a list of useful tips and tricks that serves as some sort of toolbox we can pick useful tools from to make our daily business more efficient.
Before we dive deep into various tools, let's start with a very powerful shortcut. If you never heard or cared for the Find Action, you definitely don't want to miss out on one of the most obvious features. (1)
Shift + Command + A you can use any features, no matter how obscure and hidden, right from the prompt. You want to disable
Save Action, use
Find Action, type in
Save Action and you're got it done, without ever touching any menu's context or even your mouse/touchpad. Handy, right? It works with virtually anything.
If from macOS 10.14.4 onwards the hotkey opens the terminal, check out the official blog post proposing a hotfix for that annoying issue. (2)
Ever needed to make sure you regular expression is actually picking up the element you were looking for? Most certainly, you used some online service to check your regex expression. As you might expect, IntellJ does offer this service as well, right within your IDE. It called the regex check. (2)
Move your cursor over the actual regex expression and press
Option + Enter, choose "Check RegExp" in the tooltip and a new small window will open where you can tinker with your expression to make it work the way you intended to.
Another common work pattern is having some sort of code clipboard where you need to adjust some code, copy/paste it somewhere, try something else out without wanting to commit any changes to your actual projects workspace. One might be inclined to use another editor alltogether to do so, but IntellJ also offers a very handy feature here, namely scratch files. (3)
Scratch files are basically temporary draft files that don't affect your project and won't be included by your SCM of choice. They're also fully functional, syntax is being highlighted, and even runnable and/or debuggable. You can create them right from the File context menu, by choosing
New > Scratch File or by the handy shortcut
Shift + Command + N. They however persist in your project, but just not in your workspace. As soon as you don't need them anymore, scratch them.
Along with Scratch Files goes the next feature: a fully integrated support of an http client within your IDE that you can use with scratch files. There are many third-party tools like Postman (4) that basically offer the same funtionality, but having the possibility to use it right from IntellJ makes it even more comfortable to test out your web service. IntellJs own http client is pretty powerful and you should definitely check out their official documentation. (5)
Basically, you create a new scratch file by
Shift + Command + N and choose the .http (alternatively .rest) file type. In your newly created scratch file, you can now define some REST statement and you're ready to go to test them out right away.
By simply typing
GET http://www.b-nova.com and pressing the green Start icon in your lefter pane, the http client will make a GET call on said adress and write out its response. Now, you can attach as many parameters and values in order to tweak your statement to whatever need you got on your hand.
GET http://www.b-nova.com` Connection: keep-alive Accept: text/html Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8
Furthermore, there's a cURL converter functionality from within IntellJ that let's you convert cURL statements into valid .http statement. For doing so choose
Tools > HTTP Client > Convert cURL to HTTP Request from your menu's context and insert your cURL expression.
curl 'http://www.b-nova.com' -H 'Connection: keep-alive' -H 'Accept: text/html'
This would create an http body as already exemplified above.
Dependency Structure Matrix
Last but not least, we got a complicated sounding feature called the Dependency Structure Matrix. (6) What may look off-putting is actually a very easy-to-use tool that may very well improve your applications overall architecture. In a nutshell, it shows inter-dependencies between modules, files and/or classes by visually plotting them on a matrix graph. The DSP, short for Dependency Structure Matrix has been out for only a few months, and in our opinion, totally worth your time. (7)](https://blog.jetbrains.com/idea/2020/01/dsm-prepare-your-application-for-modularity/)
If you're interested in learning more what IntellJ has to offer, make sure to check out following official web sites: