In JetBrains Rider, is there keyboard shortcut to add a new class file? - rider

In JetBrains Rider, is there keyboard shortcut to add a new class file? Perhaps with the same popup to name the C# class, then to save in the currently selected/open directory.
Would save many mouse clicks :-)

To generate new class file in Rider:
Method 1
In the Solution Explorer, select a node.
Press Alt+Insert | Ctrl+N | ⌘ N.
Choose Class/Interface in the context menu.
Reference
Method 2
In the Code Editor, press Ctrl+Alt+Insert | ⌃ ⌥ N.
Choose Class/Interface in the context menu.
This will add the new file in the same folder as the current file.
Reference

There is no dedicated shortcut for a new class, but you can select a node in the Solution Explorer, press Alt+Insert, and then pick the desired template from the popup.

Related

Visual Studio 2022 How to locate current file in Class View using a shortcut?

I can use a short cut to locate the current file in solution explorer, but I can't do the same for Class View.
I don't want to always track the current file open. I want to press a shortcut and see that file in the class view.
I believe what you are seeking is the shortcut View.SynchronizeClassView. By default this has no shortcut assigned to it.
Go to Tools → Options → Environment → Keyboard and filter the shortcut list by searching for "View.SynchronizeClassView". Select the item in the list, create a shortcut of your liking, and assign it.
After doing so, when you perform the shortcut, class view should sync to where your cursor is at in the code like so:

Is it possible to view one file in a new window in intellij-idea?

What I actually want to do is to view different files in a some project on different screens.
If they are in different windows, I can easily drag one window to another screen.
It's fine if there are other ways can do this. I'm using windows7.
You can drag the editor tab to another screen and it will open in a separate window. See the Detaching Editor Tabs help section for details.
Shift+F4 does the same:
The shortcut can be changed here:
You have to add a new keyboard shortcut in your keymap.
The action is called Open In New Editor Window
Then when searching for a class using Ctrl + n (go to Class...) or Ctrl + e (recent files)
instead of opening the Class in the same window by pressing Enter
you can open it in a new window using your own keyboard shortcut (Shift + Enter in my case).
Right-click on tab.
Select Move Tab to New Window option.

Shortcut for locate current file in Project Explorer in IntelliJ?

I read this post:
Locate current file in IntelliJ
Still the problem is that I do not want to have Autosccroll from Source enabled because my Project Explorer will be jumping up and down. Rather I need a shortcut to locate the current file in the Project explorer when I need to. ALT + F1 does work but you need to select from a context menu where you would like the file to be shown. In Resharper for example the shortcut is ALT+SHIFT+L but I am not able to find such a shorcut in IntelliJ?
There is no shortcut for this action in IntelliJ IDEA other than Alt-F1.
There is no default way of doing this.
I can think of 4 options:
You can install the plugin 'Scroll From Source' which will allow you set such a shortcut in the keymap settings (Default: Meta + Ctrl + S)
Use the target symbol in the project explorer, no shortcut but is default option.
Get used to having to press Alt + F1 and then Enter
Record a macro for the above key presses but this may be unreliable. You could then assign a shortcut key to play this marco.

Choose between open declaration/implementation on Ctrl + click in IntelliJ IDEA

Details:
IDE: IntelliJ IDEA 14
O.S.:: Windows 7
If I want to navigate to the declaration of a method I can choose one of the following approaches:
press Ctrl + left click
right click > Go To > Declaration
press Ctrl + B
If I want to navigate to the implementation of a method I can choose one of the following approaches:
press Ctrl + Alt + left click
right click > Go To > Implementation(s)
press Ctrl + Alt + B
In Eclipse, if I press Ctrl and the mouse is over a method, a popup appears and I can choose what to do (go to Implementation/Declaration). If I press "left click" ( Ctrl is still pressed ) the first option will be chosen.
How can I achieve the same / a similar behavior in IntelliJ IDEA ?
There is not a built-in option for this. You would need to configure a custom quick list to do such.
Open the Settings dialog and go to "Quick Lists" (It's under "Appearance & Behavior" in IDEA 14)
Click the add button to the right of the middle pane
Give your list a name
Click the add button to the right of the far right pane (where is reads "no actions")
Add the Go to Declaration action (Main Menu > Navigate > Go to Declaration)
Add the Go to Implementation(s) action (Main Menu > Navigate > Go to Implementation(s))
Click Apply
Go to Keymap in the settings
Under the "Quick List" node, find the Quick List you just created and map a short-cut (keyboard or mouse) to it. You can, of course, remap one of the shortcuts used by the Go to Declaration or the Go to Implementation(s) action
Click OK to close out of the settings and give it a try.
Note that in the quick list that opens, you will have numbers next to each action for quick selection.
Edit:
Adding a screenshot of final quick list for additional clarity
I was looking for the same thing, because I was also used to it in Eclipse. Nevertheless, in 99% of the cases, I went to the implementation. If that's your case too, you may consider changing the Ctrl+click shortcut in IntelliJ:
Open File → Settings... → Keymap
Search for "implementation", and identify the item "Main menu → Navigate → Implementation(s)" in the list
Right-click the item and choose "Add Mouse Shortcut"
Add the Ctrl+click shortcut by making a Ctrl+left click on the window
When hitting the OK button, you have two choises :
Remove the existing shortcut (opening the declaration)
Leave the existing shortcut : In that case, when using then Ctrl+click, both the declaration and the implementation will be opened (at least when they are in different files)
I know this answer comes like 2 years too late, but hopefully it may help others?
EDIT : This shortcut also applies when you want to navigate to the declaration of a super class. Therefore, my "99%" first declared above drops a bit.
I've added the ctrl + right-click as a shortcut to go the declaration (which conflicts with no other shortcut - but you need a mouse with at least two buttons...).
If you select the method and hit Ctrl+T it will show the implementations of the methods. You can click on the options to navigate to that implemented method. Hope this helps.
On mac you can open the implementation(s) with command + option + click. Right -click on the method and check "go to" for the other options and shortcuts you might need.
My IntelliJ (2016.2) shows the declaration of a method (in a PHP interface) as one of the implementations in the implementation popup, so maybe you can do this all from the Implementations popup now.

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

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.
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.
You can also use: ctrl+alt+insert
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
For Mac Os, command + 1 , then press control + return
On Mac OS 10.14.5, Idea Intellij 2019.1.3 - Press command + 1 to navigate to project files then press control + n
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.
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.
Alt-Home until you're in Packages view
Down-arrow until package is highlighted
Alt-insert
Enter X 2
Type name
$PROFIT$
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.
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 )).
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 ...
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.