Intellij IDE for Maximum Efficiency , Shortcuts , Plugins , Live Templates
Why do we use IDEs? Because we want to increase our productivity and avoid doing dummy and simple things ourselves. IntelliJ IDEA is a powerful tool with a lot of features that help us to do so.
In this article, we will discuss how to use IntelliJ IDEA for maximum efficiency. Shortcuts, Plugins, and Live Templates are the main focus of this writing.
We will talk about shortcuts that help us navigate through files, codes, and menus; also, some essential ones to speed coding, AceJump to assist you in moving in your code, and String Manipulation to modify texts. Finally, we will see how Live templates aid us to generate structures faster.
Shortcuts
Menu Navigation
A general rule for top menu navigation is each one has an underlined letter that indicates the shortcut to use
- Alt + F: File Menu
- Alt + R: Refactor Menu
- Alt + S: VCS menu
- so on
Remember that you can move through all of the top menus once you’re in one of the them by using ⬅ and ➡ arrows.
Tool Windows Navigation
Almost every tab has a number on it; if not, go to Settings➡ Appearance➡ Tool Windows and check the Show tool window numbers checkbox.
Now for moving around, use Alt + [Number] to open and close the window. For example:
- Alt + 1: Project Window
- Alt + 5: Debug Window
- so on
File Navigation
- Alt + ⬅(➡): Moving between open files to the left (Right).
- Ctrl + Tab: Switcher. Switch from the current file to one of the recent files. Hold the Ctrl and press Tab multiple times to reach your desired file.
- Ctrl + E: Recent Files. Open the Recent Files Tab and keep it on screen.
Editing
- Ctrl + W: Extend Selection. useful when you want to replace a text, wrap an expression, or refactor part of your code. Use Shift with this combination to Shrink Selection.
- Ctrl + B: GoTo Declaration.
- Ctrl+ Q: Documentation. pressing it twice, transform the popup dialog to a window. The third time pressing, it will close the documentation.
- Ctrl + Space: Code Completion. The completion can be a name, variable, expression, or statement. Type part of the code and use this option. It is beneficial.
- Alt + Enter: Action Context Menu. Usually, this menu is represented with a “yellow lamp icon”. If there’s a suggestion or you want to disable or enable some behavior (e.g., eslint), this shortcut can be very helpful.
- Ctrl +Shift + Enter: Complete Current Statement. Well, we all have been there when the end of the statement is like …))))), and it just needs a semicolon. This shortcut completes the statement and goes to the beginning of the next line. Try it with control flow statements like for or if.
- Ctrl + Alt + T: Surround With. Select a piece of code and use it. The suggestion includes if, while, for, try-catch, with, and so on.
- Ctrl + Shift + I: Auto Indent Lines.
- Ctrl + Shift + L: Reformat Code.
- Ctrl + Alt + O: Optimize Imports.
- Ctrl + ⬆(⬇): Move Cursor Up(Down). Sometimes you need to look at something at the top or bottom of the page, but you don’t want to lose your caret; this shortcut is your saver.😉
- Ctrl + Shift + ⬆(⬇): Move Statement Up(Down). This shortcut comes in handy when you want to move statements like functions up or down. It can be applied to class, function, statements, or line;
- Ctrl + Alt + ⬆(⬇): Move Line Up(Down).
- Ctrl + +(-): Expand (Collapse). It can be applied to class, function, and control statements.
- Ctrl + Shift + +(-): Expand (Collapse) All. Same as the previous one, but it will be applied to all the code blocks.
- Alt + /: Cyclic Expand Word. Type a few letters and use the shortcut to complete the rest of the word. keep using it to find what you want. Bear in mind that the word you need must be in the file.
- Ctrl + Alt + V: Introduce Variable. Select an expression and use this combination to turn it into a variable. Use C instead of V to Introduce a Constance, F to Introduce a Field, and P to Introduce a Parameter.
- Ctrl + Alt + M: Extract Method
- Alt + Insert: Generate. I usually use it when I’m coding in Java to generate boilerplate code.
- Shift + F6: Rename File.
- Ctrl + Alt + S: Settings.
- Ctrl + Alt + Shift + S: Project Structure.
Others
- Ctrl + R: Replace Toolbar.
- Ctrl + F: Find Toolbar.
- Double Shift: Search Everywhere Window
Plugins
AceJump
AceJump allows you to quickly navigate the caret to any position visible in the editor. See a demo of AceJump in action! Hit Ctrl + ; type a character, then type the matching character to Ace Jump. This plugin is a game-changer.
String Manipulation
As the name presents, It helps you do actions like case switching, Sorting, Filtering, Incrementing, Aligning to columns, Grepping, Escaping, Encoding on strings.
Live Template
Use live templates to insert common constructs into your code, such as loops, conditions, various declarations, or print statements. IntelliJ IDEA has some predefined live templates, which are pretty awesome. Adding option is also available to declare customized live templates.
I use arrow functions a lot! Let’s create a live template for it.
- Go to Settings➡ editor ➡ Live Template➡ Javascript
- On the right side of the window, click on the plus sign to add a live template
- Set an abbreviation and a description
- For writing template text, write the constant part and use $NAME$ format for variable parts.
- Click change at the bottom of the window to declare its application; in our case, select Javascript and Typescript.
Now, whenever you are in a .js or .ts file, your live template will be suggested by typing the abbreviation.
for more information, see the documentation. Also, if the live template was interesting, the same kind of behavior is available for defining files called File Templates.
Conclusion
We discussed essential shortcuts, plugins, and Live templates to avoid repetitive tasks and to increase efficiency. Using what I just described, I believe you can throw your mouse away or send it to me if it’s a good mouse as a thank you gesture😁; because you’re not going to need it.
You think, IDE do the work
Happy Coding🍻
Sources:
- Live Templates: https://www.jetbrains.com/help/idea/using-live-templates.html
- File Templates: https://www.jetbrains.com/help/idea/using-file-and-code-templates.html
- AceJump: https://plugins.jetbrains.com/plugin/7086-acejump
- String Manipulation: https://plugins.jetbrains.com/plugin/2162-string-manipulation