reddit / emacs

How to search directories/files?

ChemicalRecording522 · 2022-11-11 20:33
I'm usually programming in vscode or intellij during my working hours and wanted to make a slow switch to emacs for my side projects. Both of these options have a "find in files" keybind (ctrl+shift+f) which I use constantly to jump around at different areas. Is there something like this for emacs? I'm on windows and have tried 'elgrep' but it just doesn't seem near as efficient as what I was using before because I have to set the directory, reg exp for files, reg exp to ignore files, etc etc... Maybe there is some way to create a command to do this for me or a better/easier to use plugin out there.
RuleAndLine · 2022-11-11 20:54
Clarifying question bc I'm not familiar with vscode: does find-in-files search just the files you currently have open? Or does it search your filesystem and open new files for you?
ChemicalRecording522 · 2022-11-11 21:10
"VS Code allows you to quickly search over all files in the currently opened folder." taken from [vscode website](https://code.visualstudio.com/docs/editor/codebasics#_search-across-files) It allows me to search all files in my project directory (since thats usually what I open from).
WallyMetropolis · 2022-11-11 22:21
I use projectile, which has projectile-ripgrep which will do this across a project. There's also rg-project from the rg package.
deaddyfreddy · 2022-11-11 22:57
> How to search directories/files? please provide exact requirements/user story, not "something like X in Y"
redblobgames · 2022-11-11 23:36
I use consult-ripgrep for this (because I use consult) but I think you will find similar things for ivy (counsel-grep) and helm etc.
andyjda · 2022-11-12 00:18
You can use `grep-find`. I haven't used `elgrep`, but it looks similar. The difference is that `grep-find` pre-fills the command with reasonable defaults, so all you have to do is type the search string (encased within quotes if it has spaces/regex). All of the command options are customizable: you can do `M-x describe function RET grep-compute-defaults` to take a look at what variables are used. But the defaults are pretty good, including setting the current directory as the default directory. If you like the command, you can then rebind it to whatever key you like (and possibly also enhance it pretty easily to do things like search for the word at point, etc).
ChemicalRecording522 · 2022-11-12 00:31
thank you
arthurno1 · 2022-11-12 06:32
> Is there something like this for emacs? helm + ag or ripgrep is really fast and works well, in my opinion.
terminal_cope · 2022-11-12 22:09
Yeah, the consult-(rip)grep commands operate on the current project or current subtree if you're not in a project. There are definitely similar facilities in other equivalents like counsel or helm.
plm314 · 2022-11-12 22:36
As others suggested perhaps also try rg (ripgrep) with the same interface but occasionally faster. You can turn the output buffer from either of those searches to editable mode and apply changes and save them back to their respective files. For quick navigation jumps within a project perhaps try also C-x p g (project-find-regexp).
Ghosty141 · 2022-11-13 09:45
Check out the affe package. I use it everyday and Im super happy with it
MrTinyToes · 2022-11-15 09:58
`grep -r "search" .`