How to close a file in Intellij using a keyboard shortcut?
Intellij IdeaIntellij Idea Problem Overview
I know this is a simplistic question; but I've been using IntelliJ for months now, and can't find this simple feature.
Any idea? Thank you.
Intellij Idea Solutions
Solution 1 - Intellij Idea
Idiot me. CMD-F4 or, as mentioned before, CTRL-F4.
Thank you all. I'll just bury myself now :)
Solution 2 - Intellij Idea
hmm you can't because there is no default key binding for that, at least on OSX, however you can go here and define one:
Solution 3 - Intellij Idea
The standard tip if you don't know how to do something in Idea is "Find Action..." (ctrl+shift+A in Windows) then type what you want to do, in this case close
.
You will get a lot of different "close" actions and simply "Close" (ctrl+F4 in Windows) will be one of them.
Solution 4 - Intellij Idea
You can also set a custom key combination in the settings menu
Click on File > Settings
and select Keymap
from the menu on the left, then scroll down to the Other
section and set your preferred key combination for Close Active Editor
:
When you double-click on Close Active Editor
, a menu pops up allowing you to set a key combination, a mouse gesture, or even an abbreviation for the action. If the shortcut is already set somewhere else (as in my case with Ctrl-W
) you'll get a notification and won't be able to set the shortcut until you remove the other one.
Solution 5 - Intellij Idea
As with Matt Ball, I don't use IntelliJ but may also be CTRL+F4...
Solution 6 - Intellij Idea
For MAC user, Cmd-W will close the active tab (file).
Solution 7 - Intellij Idea
On Mac, you might like to use CMD + W
, as this is the conventional shortcut for closing things e.g. Tabs in Chrome.
But by default this is usually associated with highlighting the current cursor block, so instead I use CTRL + W
, rather than re-assigning.
e.g. (bottom right)
Also works for other IntelliJ IDEs, like WebStorm, etc.
Solution 8 - Intellij Idea
IDEA->File->Setting->Search for "Close Active Editor". Click on 'Add Keyboard Shortcut' -> Change it to "Ctrl+W". (Overwrite).
BOOM! you are universal now!
Solution 9 - Intellij Idea
I'm on version 2020.4 and this has changed to Ctrl+4