Our changelog, announcements, dev posts, and anything else we think you'll find interesting.
Code search tidbits: 4 underrated features
You can do some pretty wild things with Sourcegraph that you won't find in any other code search tool today. Below are 4 short-and-sweet tidbits of underrated search features that go a bit extra.
Find repositories by description
repo:has.description(scientific computing)↗ to find repositories related to topics like scientific computing. Repositories are ordered by number of stars.
Simply add a pattern like
matrix multiplication↗ to search inside repositories that match the description. Try other terms to find projects like game engines, react tutorials, or video editors.
+added or -removedSearch over code
Sourcegraph can search over diffs. But did you know: searches can pick out only
the lines that were +added or
select:commit.diff.removed to search for added
or removed library calls or
TODOs in repositories ↗.
Conditionally search repositories
Add a search term like
repo:contains(file:package.json content:eslint.*\^8\.13\.0) to search inside repositories only if they
package.json file with a specific
eslint version. For example, we
can search for the
rules field in
.eslintrc files, but only if the
repository contains an eslint version of
package.json. See it in action with this
So you basically have "if" statements without needing to do anything too
special. These are great for needle-in-a-haystack queries (so they sometimes run
a bit longer) but are extremely powerful. Check out
for similar conditional search terms.
Curate groups of repos to search over
Create your own groups of repositories to search using
search contexts. I use
this to group the top 100 starred GitHub repositories by language. It's really
handy to search for examples in a language that I'm new to, like finding how library
calls are used.
Even if you know the language, you'll see code examples in popular and high
quality repositories for that language. To create your own, just hit the
context: drop-down and manage your contexts to
create your own from there.
You can reuse others' public contexts, like the ones shown in the screenshot. These are contexts I defined to roughly track the top 100 starred repositories for many different languages. So to search over the top 100 C projects, just use my
context:@r/c-100-gh↗ to find examples. Similar for Zig, Rust, Elixir, and many others.
Want to do something with code search that isn't quite working out? Head over to our Discord channel↗ and let us know.