How do I create a new class in IntelliJ without using the mouse?

Intellij Idea

Intellij Idea Problem Overview


Is there a way to create a new class in a desired location without using the mouse in IntelliJ?

I understand there is no keyboard binding in the default keymap.

Intellij Idea Solutions


Solution 1 - Intellij Idea

If you are already in the Project View, press Alt+Insert (New) | Class. Project View can be activated via Alt+1.

To create a new class in the same directory as the current one use Ctrl+Alt+Insert (New...).

You can also do it from the Navigation Bar, press Alt+Home, then choose package with arrow keys, then press Alt+Insert.

Another useful shortcut is View | Select In (Alt+F1), Project (1), then Alt+Insert to create a class near the existing one or use arrow keys to navigate through the packages.

And yet another way is to just type the class name in the existing code where you want to use it, IDEA will highlight it in red as it doesn't exist yet, then press Alt+Enter for the Intention Actions pop-up, choose Create Class.

Solution 2 - Intellij Idea

You can also use: ctrl+alt+insert

Solution 3 - Intellij Idea

With Esc and Command + 1 you can navigate between project view and editor area - back and forward, in this way you can select the folder/location you need

With Control +Option + N you can trigger New file menu and select whatever you need, class, interface, file, etc. This works in editor as well in project view and it relates to the current selected location

// please consider that this is working with standard key mapping

Solution 4 - Intellij Idea

For Mac Os, command + 1 , then press control + return

Solution 5 - Intellij Idea

On Mac OS 10.14.5, Idea Intellij 2019.1.3 - Press command + 1 to navigate to project files then press control + n

Solution 6 - Intellij Idea

On Mac you can navigate to the location in Project view where you want to create your class and then use ⌘N followed by Enter.

Solution 7 - Intellij Idea

I do this a lot, and I don't have an insert key on my laptop, so I made my own keybinding for it. You can do this by opening Settings > IDE Settings > Keymap and navigating to Main menu > File > New... (I would recommend typing "new" into the search box - that will narrow it down considerably).

Then you can add a new keyboard shortcut for it by double clicking on that item and selecting Add Keyboard Shortcut.

Solution 8 - Intellij Idea

  1. Alt-Home until you're in Packages view
  2. Down-arrow until package is highlighted
  3. Alt-insert
  4. Enter X 2
  5. Type name
  6. $PROFIT$

Solution 9 - Intellij Idea

If you use Mac, you are in luck. One can change the keymap for Intellij as Mac OS X, then you can use option+C.

Solution 10 - Intellij Idea

In my (linux mint) system I can not get working combination alt+insert so I do the next steps:

alt+1 (navigate to "tree") --> "context button - analog right mouse click" (between right alt and ctrl) -- then with arrows (up or down) desired choice (create new class or package or ...)

Hope it helps some "mint" owners )).

Solution 11 - Intellij Idea

I also searched this answer. Equivalent of command+N on Mac OS for Windows is ctr + alt + insert which @manyways already answered. If you searching this in settings it is in Settings > IDE Settings > Keymap, Other > New ...

Solution 12 - Intellij Idea

If the difficulty is in finding the option that makes .java or .class files (Like me), then simply,

click on the folder you want to create file on. select new, and type file's name along with extension.

For example, instead of, helloWorld type helloworld.java or any file extension you desire.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJavaRockyView Question on Stackoverflow
Solution 1 - Intellij IdeaCrazyCoderView Answer on Stackoverflow
Solution 2 - Intellij IdeamanywaysView Answer on Stackoverflow
Solution 3 - Intellij IdeaRodislav MoldovanView Answer on Stackoverflow
Solution 4 - Intellij IdeaVishal NagpureView Answer on Stackoverflow
Solution 5 - Intellij IdeaAdelinView Answer on Stackoverflow
Solution 6 - Intellij IdeaIvaylo ToskovView Answer on Stackoverflow
Solution 7 - Intellij IdeaMichael DorstView Answer on Stackoverflow
Solution 8 - Intellij IdeaJason DeMorrowView Answer on Stackoverflow
Solution 9 - Intellij IdeaAlan DongView Answer on Stackoverflow
Solution 10 - Intellij IdeaAndrewView Answer on Stackoverflow
Solution 11 - Intellij IdeaBohdan MyslyvchukView Answer on Stackoverflow
Solution 12 - Intellij IdeaShrishti SharmaView Answer on Stackoverflow