Navigating Between Files in the IDE: Best Practices

Posted on by Egor Malyshev

Working with multiple files in the editor is par for the course. The challenge, however, is not to get lost in zillions of editor tabs opened for each file in the editor pane. Luckily, smart tab management and a few navigation techniques go a long way toward helping you find your way around opened files quickly and efficiently.

This functionality is available in IntelliJ Idea, PyCharm, WebStorm, PhpStorm, RubyMine, and AppCode.

  • Navigation to next/previous tab. Right-click the current editor tab and choose Select Next/Previous Tab from the context menu, or press Alt+Right / Control Right (Cmd Shift ]) or Alt+Left / Control Left (Cmd Shift [), respectively. The focus will move to the next editor tab to the right / to the left of the active one.
  • Invoke Switcher to see a list of recently opened files and switch between them easily. The file being edited right now is highlighted. Invoke switcher with hotkey Ctrl+Tab or Ctrl+Shift+Tab.Here’s an even more convenient way to jump to any recently opened file: bring up the Recent Files window with Ctrl+E / Cmd E and just type the name of the file you want to navigate to. Every file/tab you switch to remembers the position of the cursor, so you can resume editing exactly where you left off.

  • Going back and forth through the history of edited files. On the main toolbar, click back / forward arrows; choose Navigate | Back / Forward in the main menu; or press Ctrl+Alt+Left / Cmd Alt Left or Ctrl+Alt+Right / Cmd Alt Right. This approach lets you move back and forth through your navigation history. It’s most useful when you need to get back to the line you were editing before navigating to an implementation/declaration/usage/etc. You can also use Navigate | Last Edit Location (Ctrl+Shift+Backspace / Cmd Shift Backspace) to get back to the last place you were editing. On a Mac OS X computer, you can also use the three-finger right-to-left and left-to-right swipe gestures.
  • Pinning and Unpinning tabs. When you pin a tab, you make sure it won’t be automatically closed when the editor starts closing tabs because of tab limitations. Also, when you close editor tabs, you have an option to keep pinned tabs opened and close only the unpinned tabs. A special round ‘tack’ symbol appears when the tab is pinned. It’s very convenient to pin the tab you often go back to so it’s not closed accidentally:
    To pin an editor tab, switch to it, right-click it and choose Pin Active Tab from the context menu. You can unpin the tab in a similar way.

  • Detaching editor tabs. In case you need more space for editing your source code, PhpStorm and other IntelliJ Platform IDEs make it possible to detach editor tabs, and move them to separate frames. To detach an editor tab, drag it outside of the main window. The contents of the editor tab is opened in a separate frame. To attach an editor tab, drag it from its frame and drop into the main IDE frame until the tab name appears:
    You can also move editor tabs between split panes.
  • Splitting and Unsplitting editor windows. Splitting the editor window divides it into individual panes. You can split the editor window into as many panes as you need, each one containing one or more tabs. Each pane can be positioned vertically or horizontally:
    Splitting helps create different editor layouts, organize tabs into groups, and edit multiple files at the same time. For example, you can scroll through part of a file, having at the same time the possibility to view the lines in its other part. To split an editor tab, switch to the tab you need, right-click its header and choose Split Vertically or Split Horizontally from the context menu. To remove splitting, just switch to the tab, right-click its header and choose Unsplit or Unsplit All:

You can customize the behavior of editor tabs in Settings | Editor | Editor Tabs. For example, you can configure how many tabs can be opened at a time, as well as their appearance, position, closing policy and other options:

Give these features a try – navigate between files in the IDE effectively, make editor tabs work and look the way you want and never again get lost switching between files!

For more best navigation practices, please see our recent blog posts “Finding Your Way Around Your Code” (Find action; Go to file, class, declaration, symbol, line; Find usages; and Search) and “Navigating your code with bookmarks” (Anonymous bookmarks and Bookmarks with mnemonics).

Develop with pleasure!
– JetBrains Team

Comments below can no longer be edited.

15 Responses to Navigating Between Files in the IDE: Best Practices

  1. Tropper says:

    February 13, 2013

    The new “Recent Files” is really cool. Never used it much in the older version but I really used it since IDEA 12. But what exactly is the difference between the “Switcher” and the “Recent Files” dialog?

    Its always funny to come here and see that there I so much stuff I never knew about IDEA. 🙂

    • Mikhail Vink says:

      February 13, 2013

      They just operate in a different way. For example, Switcher is a floating dialog closed when you don’t have Ctrl pressed – you press Ctrl+Tab to invoke it and then Ctrl+Tab more and more navigating between items on the left and right. It’ll show you only 10 (=tab limit which is configured in settings) recent files (currently opened).

      Recent files dialog with Ctrl+E is fixed as normal dialog when invoked. So it’ll not disappear if you no longer press Ctrl (as Switcher do). So you can use search among recent files. Moreover, it’ll display more than 10 recent files (even those closed by the tab limit setting).

      Just try and compare =) You will find a lot of small, but yet so convenient things!

      • Tropper says:

        February 14, 2013

        So I tried it at home on my Mac as well as at the office on my Linux machine. Works fine on Linux, although I’m still not sure why I should use it. I personally prefer the “Recent Files” dialog.

        On the Mac however I’m unable to navigate between files because I have to keep the CTRL key pressed – but CTRL and cursor keys do trigger fancy OSX features.

        But like I said, not really a problem because the new Recent Files dialog is awesome and does the trick for me! 🙂

        • Mikhail Vink says:

          February 14, 2013

          On Mac OS X if you use 10.5+ keymap some hotkeys are different and for navigating between files (next/previous file/tab) it’s not Ctrl Left/Right, but Cmd Shift [ and Cmd Shift ] respectively as some OSX fancy features really overlap PhpStorm’s hotkeys on the system level.

  2. Jeff Schwartz says:

    February 13, 2013

    Cmnd shift n and just start typing the name of the file. You’ll get a list of all matches from which to select from. Great because I never have to take my hands off the keyboard.

    • Mikhail Vink says:

      February 13, 2013

      Oh yes, that’s a really good one! There are more tips on code navigation of this type in the previous blog post

      • Jeff Schwartz says:

        February 14, 2013

        I use most if not all of those as well plus I’m using Vim key mapping. My ultimate goal is to never have to take my hands off the keyboard and with WebStorm that’s almost possible and that’s just one reason why I swear by it.

  3. Johannes Hardmeier says:

    February 13, 2013

    “The challenge, however, is not to get lost in zillions of editor tabs opened” .. thats exactly why there should be tab-groups. All the navigation is nice and speeds up development, when you have one issue to deal with. As soon as you are working on several issues with their respective files none of those tools help you.

    Tab groups – in short – are groups of tabs the user can define – they are for example listed above the regular tabs and only the tabs of the currently selected group(s) are visible. You can switch between groups, open, close or save a group(i.e. all files that are defined in one group).
    For more see (& vote) here

    • Andriy Bazanov says:

      February 14, 2013

      Try Tasks and Contexts — I work with Tasks without VCS — just using them as “set of predefined tabs/files” — works fine for my needs.

  4. Mike Schinkel says:

    February 14, 2013

    Thanks sir, may I have another? 🙂 Been using PhpStorm religiously since pre-1.o and I didn’t know half of these! Please keep these kind of articles coming.

  5. wersoo says:

    February 14, 2013

    BTW, it seems that [Alt]+[←] and [Alt]+[→] doesn’t work correctly with tabs sorted in alphabet mode.

  6. Jamie Craane says:

    February 14, 2013

    When working on a specific feature which involves several files editing simultaneously, I often use Ctrl+Shift+E to get an overview of recently edited files. This makes me jump back and forth to the files I edit very quickly.

    A while back I wrote a post about customizing the IntelliJ editor to fit your needs. You can find it here: Maybe it helps.

  7. Karlheinz Stohnemann says:

    February 20, 2013

    I really, really love this kind of best practices hints. I did neither know of cmd+e nor of cmd+shift+n. But as Mac user I have the same issue with Cmd Shift [. Is there any way to get around this to switch just between the opened tabs?

    • Mikhail Vink says:

      February 20, 2013

      The default hotkey in Mac OS X 10.5+ for switching between opened tabs is Cmd Shift [ and Cmd Shift ], you can also set hotkey you are comfortable with in Settings | Keymap, but some hotkeys are defined by Mac OS X system (such as Ctrl Left/Right) so you can’t actually use them. However, some Mac Os X hotkeys can be disabled in system preferences and then they become available.


Subscribe for updates