How to search better with Atom

I’ve been using Atom as my text editor for longer than any other text editor now, after using Textmate, Sublime Text, and Vim for a couple of years each. In this post, I show a little tip I’ve discovered to help make searching more powerful.

This is nice, and it’s common to search for a pattern like some_function or some class like Page in your existing project.

This example here shows a personal site I used to run, searching for mentions of Page in an django project:

I’m getting all kinds of maches, including ones in files I don’t want

However, lets say you’re working on an app, where you’re sure you don’t want to look in some kinds of files that also end in .py. This might be some migration files, which are written in python, but you know you won’t want to look in them for code that controls how an application works right now. To filter out all the migration files, you can and a second negated pattern, by adding the bang/exclamation mark instead, like so:

That’s more like it, no migration files in the search results. Huzzah!

Searching across files you normally want to ignore in a project

The other handy trick I’ve started using a fair amount of late, and especially since I started writing in javascript and python more is toggling the search behaviour between to ignore the files that you have told git to ignore with a .gitignore file, and including them when you’re trying to understand where a given bit of code came from.

You can do this the quick and dirty way by opening up Atom’s config file here:

And in the config.cson file that’s presented ​to you, making sure you have this property set to either true or false:

“*”:
core:
excludeVcsIgnoredPaths: true

If you have this set to true, you’ll have faster searching of just the files and folders you have decided to ignore with your gitignore file. But if you do need to search for something in something like a node_modules folder in javascript, in a virtual environment in Python, you can toggle this by setting this value to true or false.

I only really discovered these this year, and it’s not something I new how to do before, and I figured Atom others might find it useful too.

Hope it helps, and happy searching! If you use Atom, and there are any other gems like this, feel free to add a comment below.