31
votes
Accepted
Counsel M-x always shows "^"
ivy-initial-inputs-alist is a variable that controls the default minibuffer contents when using ivy (which is used by counsel).
The default "^" string means that if you type something immediately ...
18
votes
How do I find text across many open buffers?
swiper-all from the swiper package provides a tool for doing this. It's even incremental, so it updates as you type.
17
votes
Accepted
Search through the values of all variables in Emacs
Does apropos-value do what you're looking for?
(apropos-value PATTERN &optional DO-ALL)
Show all symbols whose value’s printed representation matches PATTERN.
PATTERN can be a word, a list of ...
12
votes
Getting number of occurrences, during incremental search (C-s / isearch-forward)
As of Emacs 27.1, this is now built-in to isearch.
To turn it on, put the following in your .emacs file:
(setq isearch-lazy-count t)
Next, reload your .emacs file via M-x load-file.
To compare with ...
12
votes
Accepted
Does "Occur-at-point" already exist?
There are a number of Emacs commands for which M-n at the input prompt (next-history-element) will insert a reasonable default if there is no next history element available. For occur that happens to ...
10
votes
Accepted
Difference between `evil-search-forward` and `evil-ex-search-forward`
evil has two search implementations, one is its own, the other one is a wrapper around emacs isearch. evil-search-forward wraps isearch-forward, evil-ex-search-forward invokes the internal search.
...
10
votes
Accepted
Is there a more efficient alternative to search-forward when searching for a single character?
I have run the following benchmarks on
GNU Emacs 27.0.50
(build 14, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
of 2018-02-21
without customisations, i.e. by starting Emacs with the -Q flag.
...
10
votes
Accepted
Swiper get last search term
When you invoke swiper press M-p to search for previously searched thing.
M-n will let you search for the word under cursor.
C-s will search for the next occurence.
UPD, thx @Basil
After you ...
9
votes
How to search in multiple files with Emacs without grep?
The Elisp package elgrep is a swiss army knife for searching files.
It is available on melpa.
There are no dependencies on external tools as long as you do not search the contents of pdf documents.
...
8
votes
What is the easiest way to search all useful files inside a single project?
If your project uses Git, you only need counsel https://github.com/abo-abo/swiper
counsel-git to find file
counsel-git-grep to grep
The only dependency is git
Text grepping is faster than the ...
8
votes
Is it possible to insert word at point in swiper?
You can insert symbol at point with M-n - the same key as the history forward, which is one of the recommended Emacs workflows for inserting thing at point.
Additionally, M-j will extend the ...
8
votes
Accepted
how do I do case sensitive searches using evil/spacemacs?
Short and narrow answer
You need to set the variable case-fold-search to nil in order
to have case sensitive search. So: put this somewhere in your init file:
(setq case-fold-search nil)
See the ...
Dan♦
- 33.3k
8
votes
Accepted
How to search by tags in org-mode
org-tags-view shows matches in all agenda files: you have to add this file to your agenda files (at least temporarily). You can do that with C-c[: that adds it to the front of the list of agenda files ...
7
votes
How to search in multiple files with Emacs without grep?
You can use Windows' builtin findstr command with M-x rgrep:
(when (eq system-type 'windows-nt)
(with-eval-after-load 'grep
;; findstr can handle the basic find|grep use case
(grep-apply-...
7
votes
How to search in multiple files with Emacs without grep?
you can try the xah-find package.
https://github.com/xahlee/xah-find
it is pure elisp, and designed just for emacs without external grep tools.
7
votes
Accepted
Selecting (i.e., as the region) the current match in incremental search
Here's one approach:
(defun isearch-exit-mark-match ()
"Exit isearch and mark the current match."
(interactive)
(isearch-exit)
(push-mark isearch-other-end)
(activate-mark))
(define-key ...
7
votes
Does "Occur-at-point" already exist?
A common workflow is:
start isearch with C-s, then
search for the next word with C-w, then
run occur with the current search string with M-s o.
7
votes
Accepted
edit search string and begin search from current location
During Isearch M-e is bound to isearch-edit-string. It pauses Isearch and puts the current search string in the minibuffer so you can edit it. Just use C-s again to resume searching from the current ...
7
votes
How do I search/replace with case sensitive search?
Use isearch (C-s), turn on case sensitivity (M-c) then launch replace (M-%) from there.
M-c runs the command isearch-toggle-case-fold
M-% runs the command isearch-query-replace
6
votes
Accepted
History of search terms for evil mode?
You will find things more Vim like with the Evil search module rather than isearch search module with Evil :
(evil-select-search-module 'evil-search-module 'evil-search)
5
votes
Accepted
How to perform a search for a string inside math environments in a tex/latex document
Bundled with AUCTeX there is the texmathp utility (which, however, is independent from the TeX modes provided by AUCTeX and can be used without it), which allows you to test whether point is inside a ...
5
votes
Search and replace on lines range, numerically
I'm not sure I understand what's so great about not highlighting the
lines first.
Anyway, selecting them is easy. The vi command :20,2003s/foo/bar/g<CR> would be something like: M-g M-g 20 RET ...
5
votes
Accepted
tagging files for filtering
If you use library Bookmark+ then yes, you can do this easily. Tagging files using Bookmark+ means creating autofile bookmarks for the files and then adding tags for those bookmarks.
You can think ...
5
votes
Open search result in the same window
Something like this should work for all modes derived from compilation-mode:
(defun my-compile-goto-error-same-window ()
(interactive)
(let ((display-buffer-overriding-action
'((display-...
5
votes
Accepted
Confine avy search to a single line/paragraph
The avy commands like avy-goto-char run avy--generic-jump underneath, and that function takes a begin/end range. Here's a proof of concept modification to avy-goto-char that runs on the paragraph:
(...
5
votes
Accepted
Is there regex match at point?
Are you looking to do this from lisp code? If so, you can use looking-at:
(looking-at REGEXP)
Return t if text after point matches regular expression REGEXP. This
function modifies the match ...
5
votes
Accepted
Search/replace and replace within a block of selected text of buffer in spacemacs
Vanilla Emacs has query-replace and related commands, that stop successively at each match for your search pattern and ask whether you want to replace it, then move on to the next match. When the ...
5
votes
Accepted
How to search for headings all the way to the root heading (and preferably file name)
If you have ivy installed you can use either counsel-org-goto (current buffer only) or counsel-org-goto-all (all currently opened org buffers). Both show the outline path for each heading and ...
5
votes
How to search and replace in *open buffers*
Ibuffer is what you're looking for.
M-x ibuffer
Mark your buffers any way you prefer: using m to mark them manually, % g by regexp content-matching, * M to mark by major mode, or whatever other ...
5
votes
Accepted
Yank / copy / get into a buffer matching regex search results
C-u M-x occur \"\(#[^\"]+\)\" <RETURN> \1
(this strips the quotes)
or
C-u M-x occur "#.+\" <RETURN>
(this keeps the quotes)
occur finds all lines that match the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
search × 310regular-expressions × 48
replace × 43
org-mode × 26
helm × 25
isearch × 25
spacemacs × 11
grep × 11
evil × 10
dired × 10
region × 9
occur × 7
case-folding × 7
latex × 6
whitespace × 6
motion × 6
query-replace × 6
newlines × 6
words × 6
org-agenda × 5
files × 5
text-editing × 5
highlighting × 5
ivy × 5
swiper × 5