Search code examples
intellij-ideaphpstormkeymapping

How to create keymap (shortcut) for opening/navigating certain file in PhpStorm/IntelliJ?


Is there any way how to open/navigate certain file in current project just by hitting one key? How to map the shortcut to do this?

For example I have three files "file-one.php", "file-two.php" and "file-three.php" and when I press F12, editor would open file "file-three.php" and focus main editor window.


Solution

  • You can do this -- using Bookmarks with mnemonics.

    You can bookmark actual file instead of particular line (yes, you can do it -- just do it while focus is in Project View panel) -- you will see assigned mnemonic symbol next to the file name.

    In general:

    • Shortcuts are rather predefined and limited to 10 only ("Bookmark 0" ... "Bookmark 9").
    • By default it will be Ctrl + 1 on Windows (depends on keymap used) .. but you may replace them by another one (look for Other | Bookmarks | Go to Bookmark 0 and so on in Settings/Preferences | Keymap).
    • Obviously ... bookmarks are project specific while shortcuts are IDE-wide setting.

    Useful links:


    NOTE: if you delete such bookmarked file (e.g. a log file that gets deleted on daily basis etc) .. then such association/bookmark will be lost once IDE will not be able to locate that file/target.

    So either always keep that file present (make empty instead of deleting it) .. or re-bookmark it again.