IntelliJ IDEA Shortcuts That Makes You More Productive (hands-on)

Published: 01 August 2021
on channel: Visual Computer Science
687
23

Hey everyone and welcome back! In this video, you're going to learn the most important keyboard shortcuts that you need to know in the IntelliJ IDEA to become a more efficient Software Engineer.

All the shortcuts that I'm going to present in this video are the default ones. So we're not going to dive into custom shortcuts in this video, maybe in a future one. The first shortcut that we're going to learn in this video is CMD + 1.

CMD + 1 will toggle the project window, which is this one that contains the hierarchy of files and directories in your project. This shortcut is really useful because it allows you to focus on the code and on the files when you need them. You can navigate around with the arrow buttons in this window and it's really useful to clear out the screen when you don't really need to focus on the files and just you want to focus on the code.

If you have multiple windows open, and you want to focus on the code, there is this really nice shortcut, which is Command Shift Left and F12, which will basically clear out all the windows on the screen.

So let's focus now on the project window. And let's say you want to create a new file and instead of going and right click on the Java directory and selecting your file, you have this nice shortcut which is called CMD + N, which will display this new window with file types that you can select from. And let's say we want to create a new Java class. Just select that type and hit enter.

All right. So now let's say you have multiple files open. You can imagine having any number of files open here and visible here in this top area of the code pod. And let's say you want to close them. You have this shortcut which is called CMD + E.

What this does is to open this nice small window, which is called the recent Files window, which contains all the files which are open right now. And by hitting the Delete button or backspace, it will close the files. So instead of going and clicking on this little X button on each of them, you can just hit Command E, go on the file that you want to close, and then hit Delete, and it will basically close the file. This window is also useful to open other tabs, for example, the Gradle tab.

You can just hit Command E and then navigate here using the arrow buttons to reach to this Gradle window. You can also go here and open the terminal and other windows that you may have here.

All right. So now let's move to the actual code, because we also have some nice shortcuts there as well. So here we got an empty class with pretty much nothing in it. Let's say we want to just create a very simple field which is private.

And let's say private string, first name. And then let's say we also get last name and age, which is, of course, an integer. So those are all private fields. Now, Let's say I want to add a constructor for this class, which is initialized with all those three fields.

Now, instead of going and actually typing the constructor public main with all the parameters and then assign them in the constructor body, I can just go and tap double shift left. This will open up a really multitask window, which is very useful because it has a lot of functionality and things built into it.

You can basically search for pretty much anything you would think of that an IDE would do, and you'll be able to find that thing here. Let's say I want to type just the first letters of the constructor were if I hit enter, it will prompt me to choose the fields which I want to use for initializing the constructor.

And if I select all of them, it will create the constructor by default with all the fields initialized.

So that's really, really useful. This will save you tons of hours, as you can imagine, if you're building code for many years, using those shortcuts will save you a lot of time. And also, Let's say, if we want to create some getter and setter methods for those fields, which are simply methods that allow you to get the actual value from that private field or set it. So the first option that we can use to create a getter is by hitting option and return more option enter on the PC.

What this does is to open this contextual menu that we can use to kind of use any suggestion or option that the ID has for that particular context.

In this case, we can do a lot of things we can clean up. We can convert this for final a bunch of options that you can see here. You can also create a getter individually and also a setter. But let's say we want to create getters and setters for all the fields. If you want to do this, we can just double tap shift left and type getter.

Many more shortcuts can be found in the video itself!

Thanks for watching!


Watch video IntelliJ IDEA Shortcuts That Makes You More Productive (hands-on) online without registration, duration hours minute second in high quality. This video was added by user Visual Computer Science 01 August 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 687 once and liked it 23 people.