Flow Notes: Searching is Typing
Recently I became aware of some habits that slow me down and occasionally break the flow when I’m behind my Mac. I began to document and gradually replace them with more productive new habits. While I cannot claim that I’ve effectively fused with my computer, I am proud of my progress. And today I’m starting a series of posts under a common title “Flow Notes” where I’ll share some of my findings and observations in hopes that they’re useful to others. This first issue focuses on one of the most common routine tasks: search.
Looking for the right paragraph to quote, scanning the program menus, locating a file or navigating a hairy codebase: all of these take more time than may seem on the surface. Over and over again I’d catch myself mindlessly scrolling through a web page looking for an elusive endpoint’s description, or clicking through a multi-level popup menu in order to reach a certain action that doesn’t have a factory shortcut. Later, having admitted my own flaws, I’d watch other people’s screens in the office and at local meetups and notice the same patterns: scrolling, clicking, hovering their mouse pointers over lengthy lists. This observation daunted me, because computers are amazing at crawling through vast amounts of data while human’s time is much better spent thinking. It would be smart to play to our own strengths, wouldn’t it?
I noticed that I wasn’t as prone to this mindless wandering around within the confines of my programming environments. I first attributed that to intellisense and internalized shortcuts, but had to admit that I often neglect both, mainly relying on… fuzzy search. My first experience with fuzzy search in a development environment was Sublime Text 2. After a mere day with it, I recognized it as one of the greatest UX breakthroughs of all time: just a few keystrokes easily save seconds of scanning menus and clicking through deeply nested file trees. Thinking about this made me realize that I’ve been subconsciously drifting towards similar kinds of navigation in other areas: with Alfred on my desktop, the “smart” address bar in my browser, the history search in the terminal. If I were to put this simply:
Searching is typing
Having coined this motto, I started a new quest: this time, for a more active way of navigating my Mac. Unfortunately, as I’ve written before, software often lets us down by imposing seemingly arbitrary restrictions on which tools can play together. That is to say: sadly, there is no “fuzzy search for everything”. What follows below are my attempts at finding reasonable alternatives to this kind of experience in the contexts I care about the most.
The easy part. With an exception for Vim, every single editor I use supports great fuzzy searching out of the box: Sublime Text, VSCode, and IDEA (honestly, the only shot I ever had at finding anything in IDEA). To stay in the flow while programming, I find it essential to internalize the shorctus for fuzzy-searching at least the following three categories: files in the current project, method and function names (both within the current file and globally), and editor commands.
When it comes to Vim, The Minimalist’s voice turns on in my head and remonstrates any hint of interactivity, especially if it’s at the price of a new plugin. Still, seeing that even a vimmer as devoted as Gary Bernhardt recommends the Command-T plugin over the built-in buffer management made me accept this as necessary evil.
These days I do quite a bit of my programming work on GitHub. The fuzzy file search (aka the file finder) triggered by pressing
t is another convenient feature that I try to use more often.
Note that it’s not just the fuzzy search that’s useful: the regular, pattern-based search is indispensable for navigating within files. I find that, often, typing the name of a variable at the opposite end of the screen is the most efficient way to navigate within the file.
I rely heavily on Alfred to get around my Mac: launching apps, finding files, triggering web searches, and custom workflows. Lately, I’ve been trying to build a habit of relying on the devdocs.io Alfred workflow instead of searching for method names online. Old reflexes die hard, but it feels good every time I remember to use the Alfred shortcut.
Now there is a little macOS trick that I’m almost ashamed for not learning years before. Remember that search field under the Help section of every application menu? I’d use it occasionally, but I never bothered to look up the shortcut. Turns out it’s conveniently mapped to
⌘+⇧+/ and internalizing it is a complete game changer. Combining it with the knowledge that you can navigate menus (Finder listings, too) by typing the captions (as opposed to using the cursor keys) has given me this almost terminal-like confidence when navigating GUIs.
Unless I’m reading an article, page search is my go-to way for navigating any web page. I assume that this is fairly uncommon because so many websites today try to highjack the browser’s shortcut (
⌘+F) for their in-app search (why would you do that). Since I started documenting my “flow-breakers”, I discovered that in Firefox (and also Chrome, but not Safari, which was my default browser), you can use page search to navigate to a link and then press Enter to open it. I was finally sold on Firefox when I learned about their
' (single quote) shortcut: it is page search limited to links only.
One of my other harmful habits was aimless switching through open tabs in search for the one I need to look at. In this case, an article stored “for later” can easily throw you off the productive path. Even though I’m a compulsive tab closer, I’d still sometimes get lost within the 5-10 tabs I open at a time. I’d never known, but it turned out that you could search multiple tabs. Safari provides a
⌘+⇧+\ shortcut that triggers the so-called “Tab overview” where you can search tabs. The downside is that there’s a shortcut for jumping to the best match. It seems like you must click on it. Boo, Apple. Luckily, Firefox does better here too: focus the location bar (
⌘+L), then enter
% followed by space and the search term.
Also, Imagine how much more useful Mission Control could be if it could search across every open application window.
The amount of text we all deal with at the terminal can easily be overwhelming. One command line tool that I’ve found to be almost indispensable is fzf. I pipe the output of any command to it and get blazing fast fuzzy search in return. Paired with
pbcopy, it’s often the easiest way of finding a line of text and reusing it for your next command. When fzf is not available (e.g., I’m in a production environment without my choice of tooling), the good old
cat filename | grep combo can serve as a reasonable alternative.
Staring at a long unformatted JSON output is one of the least productive things one can do. I learned the following trick from a colleague and have used it several times already: pipe your JSON into a utility called jq and then “grep” the output. I can even fuzzy-search with fzf if I wish to.
curl -s https://status.postmarkapp.com/api/1.0/status | jq . | grep last
When discussing fluent use of the terminal, it’s important to note that minimizing the amount of typing is as important. I rely on
^+R to scan through the command history and reuse the longer bits (my
^+R is now mapped to
fzf). I’m yet to internalize some of other useful Bash variables such as
!$ (first/last argument of the previous command), but I’ll surely get there one day.
That’s all for today. If you know other quick navigation tips, let me know on Twitter.