Questions tagged [grep]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
30 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 ...
0
votes
1answer
57 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
2answers
50 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 ...
0
votes
0answers
33 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?
0
votes
0answers
12 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
0answers
39 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 ...
1
vote
2answers
70 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/...
2
votes
3answers
71 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
1answer
94 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
1answer
42 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 - \[ \] ...
0
votes
1answer
101 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_ ...
1
vote
0answers
33 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 ...
0
votes
1answer
111 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-...
2
votes
0answers
29 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 ...
5
votes
0answers
136 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 ...
0
votes
2answers
122 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
1answer
329 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 ...
2
votes
1answer
110 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, ...
1
vote
1answer
44 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 ...
4
votes
4answers
874 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 ...
0
votes
0answers
79 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 ...
0
votes
1answer
93 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
0answers
71 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 ...
3
votes
3answers
419 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
1answer
554 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
votes
2answers
311 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". ...
3
votes
1answer
172 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
1answer
449 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 ...
1
vote
1answer
272 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?
1
vote
0answers
45 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
1answer
660 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 ...
1
vote
1answer
182 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 ...
5
votes
2answers
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
1answer
301 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
1answer
54 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 ...
9
votes
3answers
365 views

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 ...
1
vote
3answers
189 views

How do I create a command that searches a specific directory?

I would like to create a command (C-s C-k or something?) that searches a specific directory every time I call it. It would search files within that directory for a string (may contain spaces) and then ...
3
votes
2answers
200 views

How can I create a new buffer for the second run of grep, to avoid overwriting the results of the first run of grep?

When I run grep by M-x grep, I get results in a buffer. When i run grep again M-x grep, the new results overwrite the previous ones in the same buffer. How can I create a new buffer for the second ...
6
votes
3answers
1k views

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 ...
2
votes
3answers
134 views

Is there a command in emacs similar to `find` in findutils?

In emacs, the command M-x grep runs grep program. Is there a command in emacs for running find in findutils, or do similar thing? Thanks.
4
votes
2answers
335 views

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 ...
1
vote
0answers
88 views

Can emacs emulate zgrep -a in zrgrep?

Currently I can grep (in command line) the gzip files I receive using the command zgrep -a something logs.tar.gz it outputs every line inside the logs.tar.gz but without the file where it was found, ...
3
votes
1answer
719 views

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.
2
votes
1answer
160 views

grep/ag/etc results buffer: how to strip leading whitespace?

I'm using ag.el as a front-end for the ag search utility. The results are displayed in a compilation buffer in the form <file>:<line>:<column>:<matching-text>. The matching-...
5
votes
1answer
61 views

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 ...
4
votes
3answers
727 views

Multiple grep results buffers

Let's say I want to grep word1 and word2. If I use the grep command for word1 I get the results in the *grep* buffer. If I then use the grep command for word2 I loose the old results and get the ...
0
votes
1answer
202 views

How to enable “Entering Directory” matching in grep output?

I have a grep-like script that I run via M-x grep, that changes its working directory, but outputs make-like "Entering directory `/a/b/c/d'" messages (to keep emacs informed). This has worked fine ...
16
votes
5answers
8k views

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 ...
5
votes
2answers
303 views

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 ...
3
votes
1answer
250 views

How to align grep output?

I use grep-mode for a set of files and wgrep (writable grep buffer) for editing them. The buffer usually looks like: I want to find a way to change the view like this: wgrep and compile-goto-error ...