IntelliJ Idea tps & tricks
Omar Ismail
Senior Software Engineer @ Digitinary | Java 8 Certified? | Spring & Spring Boot?????? | AWS? | Microservices ?? | RESTFul Apis & Integrations ?? FinTech ?? | Open Banking ?? | Digital Payments and Transformation??
IntelliJ IDEA?is an excellent all-rounder IDE by Jetbrains. It's most often used for Java and Kotlin, but can also be used to develop for JS, Rust, and many more languages. It's what I use for most of my programming, and so I thought I'd share what config tweaks, tricks, and plugins I've used that make it nicer.
Dracula? Make it darker!
Darcula is a very nice theme, but it always bugged me that it wasn't nearly as dark as the light theme is light. It felt like there was more potential there.?Darcula Darker, by Vecheslav Druzhbin, darkens backgrounds, contrasting it more against text.
Rainbow Brackets
This plugin?may sound silly at first, but rainbow brackets honestly vastly improves readability of nested brackets. It works by giving each pair of brackets its own colour, so that nested sets are visually distinct.
While we're on the rainbow topic, for those who work with CSV files often,?Rainbow CSV?may be useful.
Errors should be visible!
Sometimes, in very dense code, it can be difficult to find a single-character syntax error at a glance, as its signified by a tiny red squiggly line. How do you fix that, and make it stand out? Add a red highlight, too!
(This can be done by going into Settings -> Editor -> Color Scheme -> General -> Errors and Warnings -> Error and setting Background to #630202)
Comments are for humans
Remove default file and code templates
From my perspective these templates pollute your code and give no benefits. You can find author and dates in VCS logs.
Auto Import
Stop doing importing manually. When the class is unique IDEA will automatically add it to the imports. Same with optimizing imports. If import is unused in my code then it shouldn't be there.
Inspections
IntelliJ have some cool inspections. By default some of them are disabled. I highly recommend you to go through inspection list and check ones you prefer. Especially in?Class Structure,?Class maturity issues,?Code style issues,?Probable bugs?sections.
IDEA will analyze your code and show warnings with possible fixes. You can increase quality of the code and encourage some good practices in the project for free.
IntelliJ doesn't run full code analysis on the fly. In order to run all configured inspections use Analyze -> Inspect Code action. Don’t forget to assign a shortcut for it!
VM Options
Working on a big project with thousand classes? You would prefer to adjust your IDE VM options. VM options are located in?IDE_HOME\bin\idea[64][.exe].vmoptions?file.
-XmsXXXm
-XmxXXXm
-XX:MaxPermSize=XXXm
-XX:ReservedCodeCacheSize=XXXm
In Java 8 PermGen memory space was removed. Metaspace is replacement for it. If you are running Java 8 then you need to use these options:
-XX:MetaspaceSize=XXXm
-XX:MaxMetaspaceSize=XXXm
Plugins
There is?Plugin Repository?with many useful plugins for IntelliJ IDEA.
During first installation IntelliJ IDEA offers to enable some bundled plugins. Disable ones you don’t use, this will speed up your IDE.
Gerrit
We use Gerrit as code review tool in our company.?Gerrit?plugin allows doing reviews directly from the IDE.
Bash Support
Doesn't come out of the box, but can easily be?installed. If you are writing a lot of scripts?quick definition look-up?(Ctrl+Shift+I) and?navigation to declaration?(Ctrl+B) can save your time.
Key Promoter plugin
Do you wish to learn shortcuts fast? I’d recommend you to get?this?plugin. It displays popup whenever you do an action with mouse instead of using shortcut. If you repeat an action multiple times it suggests you to assign shortcut to that action.
String manipulation
Straightforward?plugin?which saves you tons of time and efforts. By default context menu is mapped to?Alt+Shift+M.
.ignore
This?plugin?makes me happy. It goes beyond simple .gitignore support. Syntax highlights, file generator and user templates support. I don’t need to store personal .ignore file anymore.
Navigation
Navigation without mouse is a must! Put a?printed reference?under the keyboard and start learning the keys. Try to minimize interactions with mouse.
My favourite shortcuts are:
- Recent Files — Ctrl+E (open popup and type for search)
- Hide active window — Shift+Esc
- VCS quick popup — Alt+BackQuote(`)
- Go to class — Ctrl+N
- Go to file — Ctrl+Shift+N
- Show usages — Ctrl+Alt+F7 (I prefer to have it on Alt+F7)
- Navigate back/forward — Ctrl+Alt+Left/Right
- Extract method/variable/field /constant/param— Ctrl+Alt+M/V/F/C/P
- Select current file or symbol in any view — Alt+F1
- File structure popup — Ctrl+F12
- Open quick definition popup — Ctrl+Shift+I
Instant keymap switching
You wonder why this could be needed? Pair programming! Many of us customize shortcuts we use in IDE. If you often pair program with your mate share your keymap settings. Later you can switch between keymaps at no cost.
Simple and fast:?Ctrl+BackQuote(`)
领英推荐
Analyze Stacktrace
A very convenient way to analyze stacktrace available outside your IDE. For the first time go to?Analyze -> Analyze Stacktrace.?Check?“Automatically detect and analyze thread dumps…”.?Now whenever you copy stacktrace to your clipboard and switch to IntelliJ IDEA it will show popup with formatted stacktrace.
Basic IDE Functionalities
Let’s first talk about some of the hidden yet powerful functionalities that IntelliJ Idea provides —
Add Maven/Gradle dependency on the go!
You can?add a dependency in your POM XML file directly from your IDE?without visiting any online Maven dependency finder website. Yes, the IDE provides you the dependency template along with the exact values of artifact and group ID along with the version.
You just have to press Alt + Insert in your POM XML file.
Irritating Intention Bulb can be disabled!
Sometimes, the intention bulb can be troublesome to you and we have a fix for this too. You can disable the intention bulb under?Settings →Editor →Intentions.?Clear the checkboxes and there you go! ??
Analyze formatted stack trace from other platforms!
Do you have any error logs from Openshift, Jenkins, or Command-Line? And viewing in Notepad++ isn’t a good solution? In IntelliJ Idea, you have the?capability to view formatted stack trace.
Analyze →Stack Trace →Paste the copied logs →Hit ??
Bookmark files on your IDE!
Never miss your important files to lookup using a?bookmark.
To add/remove a bookmark to a file press?F11?key. To view all your bookmarked files press?Shift + F11.
Change your shortcut setting to Eclipse, VS Code, or more…
Change your shortcut settings on IntelliJ to that of Eclipse, Netbeans, or VS Code, and more such editors.
In case you’re already familiar with the shortcuts of any IDE other than IntelliJ, change your shortcuts settings in?Keymap?using?Ctrl + (Backquote).
Less known Navigation Shortcuts
Jump directly to the text file or make a newly customized one!
Ctrl+Shift+T
You can directly?go to the test file?of the class with the same name with this shortcut. This also allows you to?create a test file?with customization method options.
Recently opened/edited files!
Ctrl+E
See the?recent locations?that you visited or the?recently edited files?with this handy shortcut.
Check Type and call hierarchy
Ctrl+H and Ctrl+Alt+H
See the?class’s type hierarchy?and a?method’s call hierarchy?with these easy shortcuts.
Paste the correct copied thing with Paste from Options!
Ctrl+Shift+V
Paste from multiple copied statements?using this useful shortcut. It is actually a savior in times!
Quick Definition without opening the actual file!
Ctrl+Shift+I
No need to switch between files to check their methods, data types, or schema. You can?directly view the object’s data and methods?from the location it is used with this magical key combination!
Visit official documentation directly from your IDE!
Shift+F1
You need to?add the official Oracle API docs?according to your Java SDK version. On clicking a Java object and pressing the shortcut given, it will directly take you to the official documentation website.
Go to File →Project Structure →SDKs →Select SDK version →Documentation Path → Click on ??? → Paste the official docs link.
For quick documentation, you can also use?Ctrl+Q
Useful and Fun Plugins
Add some plugins in your IDE directly from the?Plugin Marketplace. Go to File →Settings →Plugins →Marketplace. If you still cannot see plugins in your marketplace click on the ?? icon and choose ‘Auto Detect Proxy Settings’.
Below are some of the plugins that I use every day at work!
Key Promoter X
Learn shortcuts along with this plugin! Key Promoter X is an intelligent plugin that shows you the missed shortcuts keys for the actions you do on your IDE with your touchpad/mouse. The plugin?recommends easy navigation keyboard shortcuts?each time you miss it!
Material UI Theme
Yes, you can experience the?Material Theme UI?in IntelliJ Idea too! Choose from the various theme options that it provides and turn your IDE into an appealing look!
Tabnine
Code autocompletion?on the go with Tabnine. Add this wonderful plugin to help you write correct code with excellent suggestions.
Mario Progress Bar
You can add the 90s kids' vibe in your IDE! Search for?Mario Progress Bar?in Plugin Marketplace and there you go. Additionally, there are several such fun elements for the progress bar that you should definitely check out! ??
Develop Android apps and plugins for JetBrains IDE
1 年If you're searching for a plugin to manage your CI directly from IntelliJ. It works with many CI providers like Gitlab, Github, Travis or CircleCI, check this out https://plugins.jetbrains.com/plugin/15457-gitlab-ci-dashboard