Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Basic code searching skills seems like something new developers are never explicitly taught, but which is an absolutely crucial skill to build early on.

I guess the knowledge progression I would recommend would look something kind this:

- Learning about Ctrl+F, which works basically everywhere.

- Transitioning to ripgrep https://github.com/BurntSushi/ripgrep - I wouldn't even call this optional, it's truly an incredible and very discoverable tool. Requires keeping a terminal open, but that's a good thing for a newbie!

- Optional, but highly recommended: Learning one of the powerhouse command line editors. Teenage me recommended Emacs; current me recommends vanilla vim, purely because some flavor of it is installed almost everywhere. This is so that you can grep around and edit in the same window.

- In the same vein, moving back from ripgrep and learning about good old fashioned grep, with a few flags rg uses by default: `grep -r` for recursive search, `grep -ri` for case insensitive recursive search, and `grep -ril` for case insensitive recursive "just show me which files this string is found in" search. Some others too, season to taste.

- Finally hitting the wall with what ripgrep can do for you and switching to an actual indexed, dedicated code search tool.



I’d also point out that VSCode uses ripgrep for its search feature which is a great starting point.


It does! And I only recently learned this, and it explains why I've always found the VS Code search and replace across all files to be tremendously useful.


Also Github is a fantastic tool for searching code across repos, ones you may not even have cloned yet! Either public ones or org ones.


The new GitHub CS is pretty great indeed. Still not on par with it's role model, but getting closer.


What’s its role model?


Sourcegraph?


GitHub's code search functionality is only available to people who are logged in.

It used to be possible to perform global/multi-org/multi-repo/single-repo code searches without being logged in but over time they removed all code search functionality for people who are not logged in.

It is completely stupid that it's not possible for a non-logged-in person to code search even within a single repo[0].

It is textbook enshittification by a company with an monumental amount of leverage over developers.

(The process will presumably continue until the day when being logged in is required to even view code from the myriad Free and Open Source projects who find themselves trapped there.)

[0] Which is why I, somewhat begrudgingly[1], use Sourcegraph for my non-local code search needs these days.

[1] Primarily because Sourcegraph are susceptible to the same forces that lead to enshittification but given they also have less leverage I've left that as a problem for future me to worry about. (But also the site is quite "heavy" for when one just wants to do a "quick" search in a single repo...)


You make it sound as if being logged in to github is somehow a big hurdle. It's free and it's easy, so why should one care if it's only available to logged in users?


yeah, I particularly like the combo regex + path: or lang:


Apart from speed, what advantages does ripgrep offer over git grep when searching git repos?


ripgrep author here.

Better Unicode support in the regex engine. More flexible ignore rules (you aren't just limited to what `.gitignore` says, you can also use `.ignore` and `.rgignore`). Automatic support for searching UTF-16 files. No special flags required to search outside of git repositories or even across multiple git repositories in one search. Preprocessors via the `--pre` flag that let you transform data before searching it (e.g., running `pdftotext` on `*.pdf` files). And maybe some other things.

`git grep` on the other hand has `--and/--or/--not` and `--show-function` that ripgrep doesn't have (yet).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: