Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala - add type definition to declaration - keyboard shortcut

Is there a keyboard shortcut for adding type definitions to Scala declarations in IntelliJ ? I cannot find any. I can find the tooltip though, but a shortcut would be nicer.

like image 332
jhegedus Avatar asked Dec 11 '16 14:12

jhegedus


People also ask

How to comment Scala code in IntelliJ?

Single-line comments in Java start with two forward slashes ( // ). To quickly add a line comment in IntelliJ IDEA, press ⌘ / on macOS or Ctrl + / on Windows and Linux.

How do I show type in IntelliJ?

In IntelliJ IDEA, you can identify the type of an expression in the following way: Place the caret at the necessary code element and press Ctrl+Shift+P (or select View | Type Info from the main menu).

How do I get Scala class in IntelliJ?

On the Project pane on the left, right-click src and select New => Scala class. If you don't see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually.


1 Answers

Unfortunately, no. The best option is as @pamu explained. Move your cursor to the variable or function declaration, type ALT+ENTER, and select "Add type annotation to definition" in the menu. You can still avoid the mouse by navigating with the down arrow and selecting with enter.

enter image description here

like image 75
lyjackal Avatar answered Oct 13 '22 00:10

lyjackal