As a programmer you often search for a specific strings or regexps in
multiple files. Previously i used to do this with the well-known
GNU-tools find and grep.
The following command searches for main in all *.go files in the
current directory and:
| |
Recently i discovered ag the silver
searcher. ag is
much faster than grep and searches directories recursively by
default. ag respects out-of-the-box your .gitignore files.
You can install ag on a Mac with brew, brew install the_silver_searcher. The following command searches all
files in your current directory for the string “main”.
| |

ag considers your .gitignore automatically but you can tweak it
even more with your own .agignore file. I put my .agignore file in
my $HOME folder so ag can find it everywhere.
| |
And if you miss your regular grep-output format, just use:
ag main --vimgrep