Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [grep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
59 views

use `ripgrep` for everything that `grep` would be used for on Windows

Given that grep is not available on windows, I'm trying to use ripgrep as a drop-in replacement so that I can use things like project-find-regexp. I don't need any extra functionality, just that ...
Charles Lowell's user avatar
1 vote
1 answer
68 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
  • 371
1 vote
1 answer
54 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
  • 135
0 votes
2 answers
526 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
87 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
122 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
  • 815
0 votes
1 answer
38 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
169 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
37 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
286 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
  • 371
0 votes
1 answer
215 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,069
1 vote
2 answers
346 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
2 votes
2 answers
2k 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
  • 143
0 votes
1 answer
251 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
  • 291
4 votes
0 answers
659 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,380
1 vote
0 answers
309 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,380
0 votes
1 answer
831 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
142 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,423
0 votes
1 answer
127 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
203 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
210 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,229
0 votes
0 answers
117 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
59 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
173 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
621 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
92 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
296 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
247 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
112 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
317 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
76 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
  • 873
5 votes
0 answers
315 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
  • 584
0 votes
2 answers
815 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
191 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
  • 153
1 vote
1 answer
72 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,260
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
  • 815
0 votes
0 answers
129 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
  • 338
0 votes
1 answer
187 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
116 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
  • 672
3 votes
3 answers
760 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
1k 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
  • 4,124
3 votes
2 answers
446 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
295 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
939 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
394 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
  • 584
1 vote
0 answers
59 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
988 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
297 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