Life Without the Project Explorer
It’s an indisputable (alternative) fact that, since Before the Dawn of Time™, or at least since GUIs became in vogue, file explorers are an essential part of any programming tool. Gotta browse them trees. It’s impossible to imagine not having your directory browser open in something like PyCharm’s Project Tool.
Or is it? I recently took my boss Hadi’s challenge. Well, I took part of it. I closed my Project Tool window and used other ways to navigate my files. And I liked it. Here are ways to enjoy Life Without the Project Explorer.
Meet You at the Bar…Navigation, That Is
PyCharm’s Project Tool is visible by default. Let’s go cold turkey and close it by clicking its hide button .
If you don’t have the Navigation Bar visible, turn it on by selecting
View -> Navigation Bar. You’ll see it appear on the first row inside your window. If you are in a deep hierarchy, you’ll see breadcrumb-like buttons, starting at the project root, all the way down to the currently-visible file:
Hmm, we have a problem. The Navigation Bar is space-constrained, so it can’t show everything in the
examples folder. You want to open the file
zorder.py. That’s a problem. But hey, we’re PyCharm, we make solutions…in this case, speed search to the rescue. You just click on the target and start typing some letters of the filename, then the list is filtered:
Like all places where PyCharm filters lists, you can use CamelHump syntax for the search expression.
Opening files isn’t the only thing we use the Project Tool for. What about creating a file in a subdirectory? Yep, you can right-click, not only on a folder directly in the navigation bar, but also inside a folder in the popup:
The other context-menu operations are also possible. Here’s one I use constantly, Find in Path:
That covers almost everything that I would have used the Project Tool for. What might you miss by using the Navigation Bar? You can’t re-organize via drag-and-drop. You can’t do anything that requires multiple selection. And while it show icons for types of files and even color-coding for VCS status, it doesn’t show coverage information.
Anything else I left off the list? Leave a comment and I’ll update this blog post.
The Navigation Bar is a nice first step away from the Project Tool window. If you want to go further and hide the Navigation Bar, what are some choices?
What Was I Just Doing?
Most of the time, I switch between a handful of files that I’m actively working on. The other hundred (or, in an npm-based project, trillion) files are in the “not urgent” pile. PyCharm has features that makes this workflow very convenient.
I’ll start with the one I use the most — Recent Files aka Ctrl-E:
Let’s say you’re editing some function, and you’re writing the test for that function. You’re switching back and forth. It’s very easy and non-disrupting: Ctrl-E then Enter — because the most-recent file is listed first and selected.
What if the file you want isn’t the first entry in the Recent Files popup? You could take your hands off the keyboard, grab your mouse, but you’ll hear the distant sounds of Hadi yelling “Go mouseless!” You could use the keyboard’s down arrow. Or…yep, as in all things, speed search to the rescue:
But maybe you just want the files you’ve recently edited, not visited. Recently Changed Files Shift-Ctrl-E might be the action/shortcut you use the most:
There’s one more…the leanest-meanest popup around: the Switcher at Ctrl-Tab. Or more specifically, Ctrl-Tab and keep holding Ctrl. The Switcher disappears when you let go of Ctrl. While it’s visible, move around with the arrow keys, or Tab/Shift-Tab to move forward/backwards in the listing and columns.
If you’re like me, these 3 choices are two too many. I currently make Ctrl-E and speed search my primary, don’t-make-me-think option.
This Tab’s On Me
It’s now confession time. I still use tabs. My last hurdle is, of all things, TDD. In Python and Angular 2, I try to write tests as I write my code, and it’s nice to see both. Though I think there’s one more level of TDD zen I can reach to eliminate even this need.
This article is by no means a harangue to tell you how to use your tool. I think tabs are ok. In fact, “highly visible tabs” was one of two things that finally made me switch from Emacs to PyCharm years ago.
At the same time, as you become more of a badass, and especially if you’re coming from a lean-and-mean editor background, you might find it appealing to turn off the Project Tool and use lighter-weight choices for navigation. A hybrid, as described in this article might be the shoe that fits your foot.
Subscribe to Blog updates
How to Connect Django With MongoDB
Learn how to use Django and MongoDB together to create a web application in PyCharm. Follow our step-by-step tutorial to connect MongoDB with Django.
New Low-Impact Monitoring API in Python 3.12
Python 3.12 adds the new low-impact monitoring API, enabling debuggers, profilers, and similar tools to run code at almost full speed.
Guest Post: Four Ways To Quickly Display OpenCV Images During Debugging
This is a guest blog post by Adrian Boguszewski, author of OpenCV Image Viewer Plugin. The average programmer makes 70 errors per 1,000 lines of code and spends 75% of their time on debugging (source). In computer vision (CV), this process may involve not only fixing the code but also checking th…