How to close a file in Intellij using a keyboard shortcut? - intellij-idea

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.

Idiot me. CMD-F4 or, as mentioned before, CTRL-F4.
Thank you all. I'll just bury myself now :)

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:

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.

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.

As with Matt Ball, I don't use IntelliJ but may also be CTRL+F4...

For MAC user, Cmd-W will close the active tab (file).

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.

IDEA->File->Setting->Search for "Close Active Editor".
Click on 'Add Keyboard Shortcut' -> Change it to "Ctrl+W". (Overwrite).
BOOM! you are universal now!

I'm on version 2020.4 and this has changed to Ctrl+4

Related

Force-Click in IntelliJ?

I'm pretty new to IntelliJ, I also have Apple's new force-click enabled trackpad. Seems like it'd be super useful to be able to assign force-clicking to a keymap action (like bringing up a javadoc for example). Is there anyway to do this? Right now if I try to assign a force click it comes up as 'Button 1'.
Thanks!
This seems to be supported now in at least 2016.2, but you have to set it up.
For instance to set Force Touch to trigger "Go to Declaration" (navigate to function/class/symbol declaration), go to Preferences->Keymap. Then search for "Declaration". Right click the entry and select "Add mouse shortcut". In the popup, perform a force-touch hard-click. Apply and you're done!

Cycle through autocomplete suggestions without arrows

I'm really impressed with the autocomplete feature of the IntelliJ IDE so far.
What I'd like to do, is cycle through the autocomplete suggestions I get when hitting Ctrl + Space without using the arrow keys (↑, ↓).
The reason for this is that I prefer to keep my fingers on the home row (I'm using IntelliJ's Vim emulator additionally).
For example, how would I select sortThis instead of sorted without using the arrow keys or the mouse?
Peter Gromov's answer brought me to a satisfying solution:
In IntelliJ's settings, for Keymap → Editor Actions → Down I set a custom shortcut: Ctrl + J.
This way I can cycle forward through the suggestions.
Setting a shortcut for Down with Selection or Scroll Line Down in the IdeaVim-specific shortcuts did not affect the selection of autocomplete suggestions though.
The answer here: https://stackoverflow.com/a/9713306/2370679 led me to discover that Ctrl+n & Ctrl+p allow navigation of the auto-complete options without having to modify any settings
For macOS the IDE will give a hint that "^↑ and ^↓ will move caret up and down in the editor". These clearly do not work.
There are a few extra steps that are needed after following #matthias-braun's solution.
Here is the full list of step that I use:
Go to Preferences -> Keymap
Expand Editor Actions (not Plug-ins -> IdeaVim)
Select Down
Click the pencil icon or right-click
Select Add Keyboard Shortcut
Press the shortcut (I use ^N)*
Repeat for 3-6 for Up (I use ^P)
Click Ok**
Go to Preferences -> Other Settings -> Vim Emulation
In the drop-down under the Handler column for the row containing Down, select Vim***
Do the same thing for Up
* If you are warned about the key binding already existing then remove it. You can always reset back to the defaults by clicking the little cog icon up the very top to the right of the drop-down menu.
** The Vim Emulation doesn't seem to be populated correctly until you reopen the Preferences.
*** I'm not sure why the Handler should be Vim. This seems backwards to me but it works.
If you're able to scroll up/down in editor with some IdeaVIM-specific shortcuts, they should also work in the completion list.
In this particular case, I'd just type another "t" so that "sortThis" becomes selected (and the only) variant.
I have done the same thing with mapping the arrows but in a more logical way:
I mapped them that when I press 'Alt' 'J' is left, 'L' is right, 'I' is up, and 'k' is down. that way I can have easy access to the arrows while my fingers are on the home row and I don't need to move them nearly as much...
I'm posting it just so people who search it on google can have that idea.

IntelliJ IDE (IDEA, PhpStorm, WebStorm): Shortcut for focusing Filter field in e.g. Change Log tool window

Is there a shortcut for focusing the Filter box in tool windows, specifically the Change Log?
See the attached screenshot to know which field I'm talking about. I searched the net and key map, but found nothing like that.
I have confirmed at Jetbrains that unfortunately it's not possible yet: http://devnet.jetbrains.com/message/5520523#5520523
Just start typing with the focus inside the tool window. IDEA invokes the search automatically. To select the item, press Enter. To cancel, press Esc.
This feature is called Tool Window Speed Search.

How do I disable the Search Everywhere shortcut?

IntelliJ IDEA 13 has the new Search Anywhere feature. It sounds like it might be useful, but so far it just gets in the way. It's mapped to some kind of magical shift-based shortcut, and it comes up every time I try to shift-click to select text. When this happens, the pop-up flickers and gets into some stuck state, so the only way to get rid of it is to click in the editor pane, which of course loses the selection.
I call the shortcut "magical" because the Search Everywhere action appears in the Settings → Keymap list with no mapping, so I can't remove this mapping the usual way. Searching the dialog for search gives no relevant results.
How can I disable this buggy feature until it's ready for production use, and get back the ability to select text?
To disable the "Search everywhere" feature, you need to invoke "Go to action" (Ctrl+Shift+A), then type "Registry...".
Scroll down to "ide.suppress.double.click.handler" and check the box.
Source: https://youtrack.jetbrains.com/issue/IDEA-161094
After updating to build 133.331, I tried assigning a normal shortcut to it in Settings → Keymap, and that made it stop appearing on double-shift.
The settings for the new version have changed
Version: IDEA 2021.2.3
Preference > Advanced Settings
Scroll down to "User Interface", find "Disable double modifier key shortcuts" and check the box.
It's called Search Everywhere, and it's present in keymap.
For me it's perfectly disabled.
EDIT As I'v found it is hardcoded now, and will popup at doubleshift source
There is also an issue at jira, about this problem.
I hope it will be fixed soon.
from: https://youtrack.jetbrains.com/issue/IDEA-161094
In IDEA 2021.2:
You could enable the Settings (Preference on macOS) |
Advanced Settings | Disable double modifier key shortcuts option to
disable it.
This problem is still present under linux (ubuntu amd64 16.10 ) on Android Studio using X11Rdp for remote connection, maybe in other situations too - the Search Everywhere dialog appear on single Shift press.
The answer is here
https://youtrack.jetbrains.com/issue/IDEA-114933#comment=27-603899
Basically you need to
Open lib/resources.jar/idea/PlatformActions.xml and remove or comment such line:
<action id="SearchEverywhere" class="com.intellij.ide.actions.SearchEverywhereAction" />
and repack the jar.
Since end of 2017 you can add -Dide.suppress.double.click.handler=true to the custom VM options: cf. the answer from JetBrains.

How to move focus to another "tab group" in Intellij IDEs

IDEs based on the IntelliJ platform let you split the editor in various ways, but I don't see an option to move focus from one editor to another using just keyboard (something like other-window from Emacs).
Is there an "action" to do that?
For mac users, the default shortcut is option + tab
I think you're already find answer, but for someone who have same question and find this post like me.
Go to Prefernces -> Keymap or simple use search in preference and find Goto Next Splitter and make your own hotkey for this action.
Main Menu Window | Editor Tabs | Select Next/Previous Tab
There's also Switcher (Ctrl+Tab) available in the same menu as Goto Next/Previous Splitter which switches between splitted editor parts, tool windows, and many other things.
For macOS it is option + tab keys to switch between tab groups
ctrl + tab works for Windows system.