Search code examples
intellij-ideaphpstormrubymine

How to create a file in a specific directory in Rubymine/PHPStorm/other JetBrains IDEs without leaving the home row


Currently, I am doing the following:

  1. cmd-1 to go to the project structure view
  2. Move to the arrow keys (not on the home row - I want to avoid this step), or, (horrors!) the mouse to navigate to the folder I want to create the file in
  3. ctrl-alt-n to open the new file dialogue, which always created the file in the selected directory

Is there a better way to specify/move to the directory without having to use the arrow keys/mouse so that I can stay on the home row?

I have tried:

  • Moving to the root of the project structure pane using pageupand typing the name of the directory - this is good, but pageup is way off the home row. Also it often selects the wrong folder (e.g. the one in /spec, not the one in /app) and I can only get to the right one with the arrow keys again. There seems to be no way to type app/controllers as it doesn't process the slash as a directory separator for some reason.
  • Using the navigation bar via option-pageup, moving all the way left with the left arrow, then either navigating to the right directory with other arrow keys, or using ctrl-alt-n from the roor and typing the full path, but this is also way off the home row and no faster.

Solution

  • Type +SHIFT+O (or CTRL+SHIFT+N if you are using Linux/Windows keymap) to open the Navigate to file dialog (or hit SHIFT+SHIFT to open the Search Everywhere dialog).

    Type the name of the directory you want to create the file in. Note that the directory name must end with / in order for IntelliJ to know that you want to open a directory not a file.

    You can type just part of the path, such as webapp/resources/

    enter image description here

    Hit Enter and the selected directory will be opened in Project view.

    Then you can use +N (ALT+Insert) to create new file as usual.