Questions tagged [grep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
32 views

How to ignore some directories with find-grep-dired?

When I search with find-grep-dired it also searches /Library/ directory and finds hundreds of cached links. Is there a way to ignore /Library/ directory? I found this : M-x customize-option <return&...
zeynel's user avatar
  • 301
1 vote
1 answer
52 views

How to create separate buffers from the ouput of grep?

Is there any way to create separate buffers for each file grep locates when running something like grep 'blabla' *.c
balanga's user avatar
  • 115
0 votes
2 answers
276 views

consult-man, consult-grep, etc. don't match anything

Emacs 29.0.60 running on Windows 10 with Msys2 and Git for Windows. I'm trying out the consult package, particularly functions such as consult-grep and consult-man, and I'm finding that I apparently ...
Rodney Price's user avatar
0 votes
1 answer
67 views

using grep on a specific file

I've read, for instance here, that one could just run M-x grep to interface with the underlying shell and just run a simple grep command. I suspect something is wrong in the setup because this simple ...
Mike Anblips's user avatar
2 votes
1 answer
97 views

Search whole ebook in nov

nov.el does not provide an easy function to search the whole of the ebook content. Every search performed on buffer only applies to the "document" or chapter of the book on display at that ...
Sati's user avatar
  • 775
0 votes
1 answer
36 views

"-o" like options for `elgrep`?

Sometimes I just want the matched result by regexp instead of the whole line, this seems possible via the -o option in grep I discovered elgrep in emacs recently, which is fantastic! Any chance we can ...
davyjones's user avatar
  • 127
0 votes
3 answers
109 views

Why can't counsel-rg index an expression previously found?

I am using trying to use a command called counsel-rg. This is the associated describe-command: counsel-rg is an autoloaded interactive compiled Lisp function in ‘counsel.el’. (counsel-rg &...
Pedro Delfino's user avatar
0 votes
1 answer
33 views

Weird behavior of `search-forward-regexp` influenced by buffer mode change

Action 1: evaluate the lisp expression: (search-forward-regexp "\\s'") in a buffer in lisp-interaction-mode containing the text: The pandemic market was cooling, but homes in north Seattle ...
Ruy's user avatar
  • 839
2 votes
1 answer
241 views

Case insensitive search with M-x find-grep-dired

I’m trying to do a case insensitive search with M-x find-grep-dired. When I enter M-x find-grep-dired and hit ENTER and enter the directory name I get the prompt find-grep (grep regexp):. I understand ...
zeynel's user avatar
  • 301
0 votes
1 answer
192 views

How to exclude certain files from helm-do-grep-1

Suppose, we have the following files: ~/1.js, ~/1.min.js, ~/bad-dir/2.js. All of them have the following contents: function hello () {} I am using helm-do-grep-1 to grep through these files and want ...
user4035's user avatar
  • 1,059
1 vote
2 answers
272 views

grep contents of a set of files from find

I want to grep contents of all CMakeLists.txt files in a project (nested within a directory) so I can jump from each instance, like I would when running emacs grep function. In the examples below I'm ...
Spacemoose's user avatar
1 vote
2 answers
1k views

Filter text of buffer in a grep-like way

I want to filter the text of an emacs buffer, a bit like you can filter text with grep. Sounds simple, but I tried googling it and I only get results from people who want to search in a buffer or to ...
Romário's user avatar
  • 133
0 votes
1 answer
214 views

How do I make `helm` save search results in a grep buffer?

I do helm-find-files (C-x c C-x C-f>), Tab, "Grep current directory with AG" (M-g a), enter pattern, Tab, "Save results in grep buffer" (F3). Now, how do I make M-g M-n/M-g M-p ...
x-yuri's user avatar
  • 281
3 votes
0 answers
579 views

How to exclude certain directories/files from `consult-git-grep` search?

I want to exlude certain files such as .gitignore in consult-git-grep search. consult-git-grep works find with following defualt setup: (setq consult-git-grep-args "git --no-pager grep -F -n --...
alper's user avatar
  • 1,300
1 vote
0 answers
290 views

How to exclude certain directories/files from counsel-git-grep search?

Would it be possible to exclude certain directories/files from counsel-git-grep search, such as .gitignore? Here I don't want to see matches in .gitignore file: I have tried adding ':(exclude)....
alper's user avatar
  • 1,300
0 votes
1 answer
759 views

How to filter search results by path pattern?

I'm using Projectile with ripgrep. I can search project lines by some pattern, as an example: test 42 will match strings like this so, test is not 42 at all I would like to be able to add additional ...
achempion's user avatar
  • 115
0 votes
1 answer
112 views

How can I get projectile-grep et al to choose the project before searching?

Projectile-grep, projectile-ag et al always execute the search in the current file's project. What I want to do is to select the project from a completion list and get projectile to search that ...
vfclists's user avatar
  • 1,371
0 votes
1 answer
109 views

Run grep (like this)

I use the standard grep command a lot. When I execute it, the minibuffer is populated with the following the text, allowing me to complete the command: Run grep (like this): grep --color -nH --null -e ...
ch-pub's user avatar
  • 220
1 vote
1 answer
177 views

Is there a way to narrow down grep results?

When I search with grep, I get the results like: -- mode: grep; default-directory: "~/code/" -- Grep started at Wed Feb 24 12:40:28 find . -type d ... that is followed by multiple lines ...
ruby_object's user avatar
0 votes
2 answers
193 views

Position the cursor at a specific point in a custom Emacs grep command

I have created this custom grep command in Emacs to search for contacts: '(grep-command "grep --color -nH --null grep -ie '^name' -A 1 ~/diary/*.org") I would like to be able to ...
Edman's user avatar
  • 1,177
0 votes
0 answers
103 views

How to use helm to search a buffer?

I would like to use the helm machinery to search "live" a buffer's lines. Is this possible? If not how would I go about figuring out how to implement this?
cammil's user avatar
  • 509
0 votes
0 answers
52 views

How can we save all the grep searches (using `M-x grep`) into history?

How can we save and retrieve all the grep searches that we do using M-x grep command into history ?
user982042's user avatar
2 votes
1 answer
158 views

How to control the way windows are opened by "next-error" and "previous-error"?

The context In the gif shown below, I demostrate that the way next-error show the current error in a new window depends on the size of the font. When using the font Fira Code 20, a single window is ...
doltes's user avatar
  • 587
1 vote
2 answers
602 views

Efficiently calling multiple variants of the grep command

The context I commonly execute the following variants of the grep command grep --color -RHIn '' (search in the current working directory) grep --color -RHIn --include='*.org' '' ~/repos/dotfiles/...
doltes's user avatar
  • 587
2 votes
3 answers
85 views

emacs grep eliminate suspects

Typically, at the beginning of a coding/maintenance task, I usually start with a carefully worded grep, such as M-x grep git --no-pager grep -n -e 'collect' -- ':!*spec*' ':!*.yml'<enter> and ...
american-ninja-warrior's user avatar
4 votes
2 answers
244 views

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 ...
Trevor Pogue's user avatar
0 votes
1 answer
50 views

List all empty checkboxes in files

Is there any easy way, including installing a package, to list all waiting checkboxes in all the files in the directory? So far I do the following for the checkboxes in a file: M-x occur - \[ \] ...
Bor's user avatar
  • 117
0 votes
1 answer
227 views

Emacs wsl grep fails on special characters

I'm using GNU Emacs 26.3 on a Windows 10 system (Virtualbox guest on Mac). The following grep command inside emacs fails: grep -i -n -d skip -e temp_ * with this error: grep -i -n -d skip -e temp_ ...
HeyMan's user avatar
  • 101
1 vote
0 answers
101 views

Abort output in currently executing command in shell mode

Sometimes in shell I end up executing a command which results in too much output. For example, consider a wrong grep on a huge text file which results in 10,000 matches. The grep command completes ...
Miserable Variable's user avatar
1 vote
1 answer
281 views

Automatic "push-mark" when navigating with xref, find-grep, etc?

There seem to be a lot of situations, where a command changes the cursor location (point), but no mark is pushed, making navigating back by popping the mark with C-u SPC impossible. For isolated use-...
kdb's user avatar
  • 1,561
2 votes
0 answers
72 views

Helm Grep within a first results set / multi line search

I would like to use helm to search for two terms which may well be on different lines. Is there a way to grep for the first term then further grep within the resulting fileset the second term? eg ...
RichieHH's user avatar
  • 848
5 votes
0 answers
280 views

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 ...
SFbay007's user avatar
  • 554
0 votes
2 answers
750 views

How can I do a regex search recursively from a directory?

Basically I want a command that can do the following: find /path/dir -type f -print0 | xargs -0 grep -l "foo" Is there an emacs command to do this? If not, then is there a convenient keybinding that ...
Prikshet Sharma's user avatar
3 votes
1 answer
1k views

How to use `next-error` and `previous-error` without the compilation buffer visible

I want to be able to use grep to find matching lines and to be able to jump through them using next-error and previous-error however I don't feel the need to have the match list on screen and it takes ...
Kevin Cox's user avatar
  • 173
2 votes
1 answer
175 views

eshell grep thinks options are patterns on windows

I'm using Emacs on windows, and was trying to run grep from within eshell (M-x eshell). The default shell through M-x is cmd.exe, but eshell has linux utilities so I'm trying to use eshell. Now, ...
archmuon's user avatar
  • 143
1 vote
1 answer
69 views

Does grepping via helm support searching for multiple words in any order like other helm completions?

When searching multiple terms with Helm separated with spaces then Helm returns the results which mach the terms in any order. This is good. Sometimes I try grep via helm. E.g. I use helm-recentf to ...
Tom's user avatar
  • 1,190
4 votes
4 answers
2k views

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 ...
Sati's user avatar
  • 775
0 votes
0 answers
118 views

Search in recent files

I use helm-recentf to receive the list of recent files. I would like to have an opportunity to search over the list of recently viewed files. Can I do it with grep or helm-swoop? Is there any other ...
Pfedj's user avatar
  • 318
0 votes
1 answer
168 views

Cannot jump to file or location link in grep-mode or compile-mode

I have recently installed emacs on a new system (Manjaro arch-linux), using my usual configuration (available here, if relevant). However, the jump function never works on this new system: whenever ...
Pierre Thalamy's user avatar
1 vote
0 answers
106 views

How to make `helm-projectile-grep` do a recursive search?

I use helm with projectile and treemacs, how do I make helm-projectile-grep command to search in all project folders recursively starting at the project root. According to this page helm-projectile ...
A_P's user avatar
  • 662
3 votes
3 answers
718 views

How to ignore backup files (~) when running grep?

M-x grep can be used to find strings in files. But I'm not interested in backup files (those whose name ends with a ~). How should I ignore those files when using the grep command?
DataHungry's user avatar
2 votes
1 answer
996 views

Grep exited abnormally with code 2

Windows 10, Emacs 26.1 M-x shell grep here result: grep Usage: grep [OPTION]... PATTERN [FILE]... Try 'grep --help' for more information. Nice. Now I want to find files in temp folder: rgrep ...
a_subscriber's user avatar
  • 3,916
3 votes
2 answers
427 views

Unable to visit file from grep results

I recently updated to emacs 26.1. Since then, grep results are not highlighted and does not contain links to files. 'n' or 'p' gives "Moved past last grep hit" or "Moved back before first grep hit". ...
Aravind's user avatar
  • 31
3 votes
1 answer
290 views

Have compilation errors / grep match reuse current frame/window without ever splitting it?

I have searched in a number of places (1, 2, 3, 4) even looked at the e-lisp source files and could not figure out how to do, so I ask. Context I have bound next-error to a key. I'm in some source ...
Stéphane Gourichon's user avatar
4 votes
1 answer
876 views

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 ...
forthrin's user avatar
  • 451
1 vote
1 answer
375 views

color rgrep matching results in the rgrep results buffer

I am liking rgrep as it lets you choose a path and searches recursively. How is it possible to highlight the matches in the rgrep buffer?
SFbay007's user avatar
  • 554
1 vote
0 answers
58 views

`find-grep` (aka `grep-find`) not finding a line when in an upper directory

[Top-posting an update] Results of deeper inquiry, after filing a bug report. It appears that the failure is related to a recent update to the cygwin environment. Where previously the single-quoted ...
Donald Locker's user avatar
3 votes
1 answer
939 views

find-grep-dired: find exited abnormally with code 1

Windows 10, Emacs 25.1, Dired+ I want in Dired to find all files that contain text "UserOptions". M-x find-grep-dired In folder ca UserOptions And here result: find exited abnormally with code 1 ...
Alex's user avatar
  • 303
1 vote
1 answer
277 views

grep view limit line lengths

When I grep inside emacs, it begins to be completelly laggy when lines are too long (just try to grep in your home emacs directory and you will see what I mean). How to set limit to line lengths in ...
dev1223's user avatar
  • 241
6 votes
2 answers
3k views

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'...
american-ninja-warrior's user avatar