• Customers
  • Case Studies
  • Docs
  • Pricing
  •  
  • Sign in
  • Get started

Blog

More powerful code search on Sourcegraph

Quinn Slack on November 1, 2017

Today, we're releasing more powerful code search on Sourcegraph.com and Sourcegraph. You can use operators such as repo: and file: to restrict your search to certain repositories and files (by regular expression match on their name).

For example, repo:foo will restrict your query to repositories whose name contains “foo,” and likewise for file:bar.

Search scopes make it easier to quickly search only among the code you care about, such as all JavaScript files or only non-vendored code.

Search scopes demo, a more powerful code search on Sourcegraph

Try it out at sourcegraph.com/search or on a self-hosted Sourcegraph instance now.

Use the search fields on the homepage to construct your query the first few times.

As you continue using it, you can express your query more quickly by using the operators (repo: and file:, etc.) in the main search box. Here are some sample queries (across a sample set of open source projects) to get you started:

  • Search non-vendored files for “open file”: repogroup:sample -file:vendor/ -file:node_modules/ open file
  • Search repositories named “mux” in test files for “new route”: repogroup:sample file:(test|spec) repo:mux new route
  • Search for occurrences of “partial<” in TypeScript files: repogroup:sample file:.ts$ partial<

Let us know what you think on Twitter (@sourcegraph). To get advanced code search for your company’s code, install Sourcegraph.

p.s. One other minor improvement: You can now select multiple lines (and share a link to multiple lines) by shift-clicking on a line number to expand the selection when you’re viewing a code file.

About Sourcegraph

  • Case studies
  • Customers
  • Pricing
  • Sourcegraph overview (PDF)

Resources

  • Blog
  • Changelog
  • Documentation
  • Learn
  • Podcast
  • Big code survey

Company

  • About
  • Careers - We're Hiring!
  • Contact
  • Handbook
  • News
  • Sourcegraph strategy
  • © 2021 Sourcegraph
  • Terms
  • Security
  • Privacy