Questions tagged [grep]

74 questions
22
votes
5 answers

How to recursively search / grep file contents in a directory / subdirectories in Emacs?

I'm using Emacs for quite some time and I still somehow fail to understand what is the best way to (recursively) grep for a string within a (project) directory and get the results presented either as a dired buffer or in some even more useful way.…
Boris Stitnicky
  • 543
  • 2
  • 4
  • 10
11
votes
6 answers

Recursive grep in directory with helm and/or projectile?

A recursive grep in a directory should be the simplest thing, but I haven't found the recipe to get it to work yet. I'm juggling between the following commands and am not sure which has the functionality buried within it: helm-find-files: The…
djechlin
  • 923
  • 8
  • 21
10
votes
3 answers

Is it possible to remove matches manually in grep mode?

After running (grep) the grep buffer appears with matches. Some of the matches are not relevant, and it would be good to remove them manually. This way I can use the grep buffer to hold only those matches which are relevant to the current…
cammil
  • 509
  • 3
  • 12
7
votes
3 answers

How to grep marked files in the dired mode of emacs?

I hope it's a simple problem.. I'd like to search for the regexp 'thisWord' only in the marked files of a dired buffer. Usually I used in the dired buffer: M-x grep and then in the mini-buffer grep -r -nH 'thisWord' . But this searches all the…
rl1
  • 346
  • 1
  • 16
6
votes
2 answers

Advanced git grep from within emacs

I've been playing with vc-git-grep as pointed to by this answer How do you grep from within emacs ( git grep 'foo' | grep baa ) I have a special requirement like this: $ git grep -e 'include' --and -e Image components/core/app/models/contact.rb: …
american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40
6
votes
2 answers

Show the matching line in the center of the screen instead of the bottom when opening a grep result

When I grep something inside emacs and click to open one of the matching files. The matching line is always displayed at the bottom of the screen, and I have to scroll it up for a better view. Is it possible to focus the matching line at the center…
6
votes
1 answer

rgrep : visiting matches without switching buffer

I was wondering if there is a way to visit the matches listed in the grep buffer without actually switching to the match buffer, similarly to C-o with Occur.
Stefano
  • 91
  • 3
6
votes
0 answers

projectile grep file filter

I'm trying to use helm-projectile-grep function on Windows 7, but it searches in every file, though in .projectile I excluded file types which I don't want to work with. Do I have to configure grep separately and how to do this? May be I should put…
Dmitry
  • 213
  • 1
  • 7
5
votes
0 answers

Sort ripgrep results based on proximity to current buffer

I use counsel-projectile-rg to search within the project I work on. But there is my sub-project inside this big repo that most of my development is in. Is there a way to sort ripgrep results based on the proximity to the current buffer that is open?…
SFbay007
  • 554
  • 4
  • 13
5
votes
1 answer

Search files by content using full boolean expressions

Suppose I want to find all *tex files recursively from a given directory containing foo and bar but not doe. I am looking for something like helm-do-ag, but that doesn't seem to support the not operator. So is there anything like that which supports…
student
  • 1,007
  • 9
  • 29
5
votes
2 answers

How to grep all the Info manuals with a regexp search

People often recommend on emacs.stackexchange.com and stackoverflow.com (in the Emacs tag) that we should learn to "ask Emacs". The built-in Info-mode is not capable of performing a recursive regexp search that can compete with the likes of…
lawlist
  • 18,826
  • 5
  • 37
  • 118
5
votes
1 answer

How can I recenter grep or compile window on next error

On next-error in the grep or compilation window, I can use something like (setq next-error-recenter 35) to ensure that window displaying the match scrolls to show the whole match, as described in more detail in this stackoverflow question. How do I…
TooTone
  • 401
  • 4
  • 11
4
votes
2 answers

How to keep grep results in eshell buffer

When entering the grep command in an eshell in spacemacs, a separate window and buffer are created to list the grep output results. However, I would prefer for the output to be listed in the eshell buffer like how a stand-alone terminal application…
4
votes
4 answers

Grep pipe support and how to filter grep results

I try to filter the output of M-x grep with grep --color=always -nH -e "text_to_find" ~/path/to/files/*.org | grep -v "text_to_ignore" but it doesn't seem to be working. The 'to be ignored' part is still not filtered away. Is it true that grep in…
Sati
  • 775
  • 6
  • 21
4
votes
1 answer

Jump to file and line number in grep file

$ grep -nrH would . | tee file.txt $ emacs file.txt If I have a buffer with grep search results, how can I make Emacs jump to the file and line number on the cursor line, similar to diff-goto-source in diff-mode? ./path/to/my/one.txt:1234 RMS and…
forthrin
  • 451
  • 2
  • 10
1
2 3 4 5