Questions tagged [grep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
56 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 ...
  • 725
0 votes
0 answers
14 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 ...
  • 127
0 votes
0 answers
11 views

Why is a git grep command on eshell generating an infinite process, a "Stack overflow in regex matcher" error, and a mini-buffer password request?

I decided to execute a grip grep -i "rcls" command on my emacs she'll. I tried that first on my iTerm2 terminal, and got this result: Since it was a bit boring to keep hitting down arrow ...
0 votes
2 answers
35 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 &...
0 votes
1 answer
28 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 ...
  • 747
0 votes
0 answers
13 views

How to refresh content indexed by counsel-projectile-rg after renaming symbols over multiple files?

I am a heavy user of the command called counsel-projectile-rg. As presented by Emacs using self-documenting tools: counsel-projectile-rg is an autoloaded interactive compiled Lisp function in ‘...
2 votes
1 answer
117 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 ...
  • 117
0 votes
1 answer
97 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 ...
  • 927
1 vote
2 answers
148 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 ...
1 vote
2 answers
580 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 ...
  • 123
0 votes
1 answer
130 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 ...
  • 271
2 votes
0 answers
376 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 --...
  • 1,112
1 vote
0 answers
201 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)....
  • 1,112
0 votes
1 answer
468 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 ...
  • 115
0 votes
1 answer
70 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 ...
  • 1,255
0 votes
1 answer
56 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 ...
  • 220
1 vote
1 answer
134 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 ...
0 votes
2 answers
143 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 ...
  • 1,103
0 votes
0 answers
76 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?
  • 509
0 votes
0 answers
33 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 ?
0 votes
0 answers
88 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 ...
  • 517
1 vote
2 answers
155 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/...
  • 517
2 votes
3 answers
74 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 ...
3 votes
1 answer
168 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 ...
0 votes
1 answer
46 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 - \[ \] ...
  • 117
0 votes
1 answer
182 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_ ...
  • 101
1 vote
0 answers
70 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 ...
1 vote
1 answer
233 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-...
  • 1,531
2 votes
0 answers
61 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 ...
  • 798
5 votes
0 answers
211 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 ...
  • 554
0 votes
2 answers
597 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 ...
1 vote
1 answer
767 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 ...
  • 153
2 votes
1 answer
161 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, ...
  • 113
1 vote
1 answer
64 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 ...
  • 1,088
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 ...
  • 725
0 votes
0 answers
99 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 ...
  • 308
0 votes
1 answer
124 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 ...
1 vote
0 answers
87 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 ...
  • 652
3 votes
3 answers
613 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?
2 votes
1 answer
855 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 ...
  • 3,639
3 votes
2 answers
370 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". ...
  • 31
3 votes
1 answer
254 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 ...
4 votes
1 answer
750 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 ...
  • 441
1 vote
1 answer
342 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?
  • 554
1 vote
0 answers
57 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 ...
3 votes
1 answer
833 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 ...
  • 293
1 vote
1 answer
255 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 ...
  • 241
6 votes
2 answers
2k 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'...
2 votes
1 answer
414 views

How do you grep from within emacs ( git grep 'foo' | grep baa )

I do this often after shelling out to bash $ git grep 'banner-image' | grep mb3 Can I do it without leaving emacs?
1 vote
1 answer
58 views

Paths not hyperlinking correctly

Recently when running compile, the error messages don't get hyperlinked properly. I get this type of error message: ../build/obj/DerivedClass.cpp:45:18: error: expected type-specifier The buffer ...
  • 345