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.
I like using Atom as an editor.
It's free, open source, polished, under constant development in the open with a well funded team, and on the whole, I agree with Alex Payne's post about the flight to old text editors feeling like mis-step.
It's easy enough to start with, and can adapt to work well with many, many languages. It's what I'd recommend to most people learning to code too.
However, because it isn't a full IDE, you do need to know how to use the search tools to get the most from it.
Searching for things that match one pattern, but not another
As the wonderful flight manual from Atom editor describes in more detail, you can search in within files, and search within projects easily, by hitting
cmd+F to search in a file, and
cmd+shift+F to search across your project.
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:
[caption width="1126" id="attachment_1034" align="alignnone"] I'm getting all kinds of maches, including ones in files I don't want[/caption]
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:
[caption width="1126" id="attachment_1036" align="alignnone"] That's more like it, no migration files in the search results. Huzzah![/caption]
node_modules directories. More here in this forum thread on discuss.atom.io.
Searching across files you normally want to ignore in a project
.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 [/code]
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
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.