The Eclipse scala plugin has a nice feature which shows you the type of a variable when you hover the mouse over it. How do I see the same information with the IntelliJ plugin?
问题:
回答1:
Select expression and type Alt + =.
If you want to change the shortcut go to Preferences > Keymap
and enter "Type Info" in the search field.
In older versions, it's Shift + Ctrl + Alt + T.
回答2:
CTRL / Command key and hover over the variable or method.
回答3:
You can hit Ctrl + Q on a variable or method signature to view its type.
There is also a neat trick to view type of any expression: select the expression and type Ctrl + Alt + V. This will show Extract variable dialog with expression type to be extracted shown for convenience.
回答4:
On OS X, it's ctrl + shift + P for me. This shows the exact type with resolved generics.
回答5:
You can set IntelliJ up sort of like eclipse. Go to:
File -> Settings -> Languages & Frameworks -> Scala
and then tick "Show type info on mouse hover after, ms" and set your preferred timeout.
This works well except that other messages seem to take preference. The most common being "Declaration is never used" which is quite a lot of the time if you have just written a val
and want to see it's type. Then you have to resort to (Alt + =) for PC or (Ctrl + Shift + P) forMac.
回答6:
In IntelliJ 2016 and later with Mac OS X 10.5+
keybindings the keybinding is Ctrl+⇧+P.
Old answer:
Under MacOS with Mac OS X 10.5+
keybindings, it is supposed to be ⌘+=, however that does not seem to work at all (for me).
In the settings (Preferences > Keymap
and enter "Type Info" in the search field),
I added the shortcut Ctrl+⌘+T to the action. This shortcut works fine.
回答7:
Hold down the Command key as you mouseover. Note: I tested this on Mac OS X with standard keybindings. Different OSes or non-standard keybindings may of course be different, but the functionality is certainly there.
回答8:
There's good tips gathered around here, but since the mappings vary by the keyboard bindings, here's a summary for the Mac OS X 10.5+
bindings.
ctrl
+ hover: show the type of the expressionalt
+ hover: clicking on the expression inspects its value (very handy!)⌘
+ hover works likectrl
+hover, but also allows clicking the link to go to other references of the expression (ctrl+click obviously doesn't because it is regarded as right click in OS X).
Note: The Mac OS X 10.5+
bindings are still not the default in IntelliJ 13.1, but they really should be. They have a more native OS X feel than the old Mac OS X
bindings. You can activate them via Preferences > "keyboard"
(in the search field) > Keymap > Keymaps: Mac OS X 10.5+
The real usability problem with these (as of IntelliJ 13.1) is that one needs to hold the key, then move the cursor. It should ideally also work when you have the cursor already on the expression, then start keeping ctrl/alt/cmd pressed in. I'll request them for this.
ps. I know it's OS X, officially, not Mac OS X. IntelliJ IDEA still uses the old naming at least for the keycaps.
回答9:
In Windows . Alt + = In mac . option + =