Skip to main content
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 ...
mkcms's user avatar
  • 1,370
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.
Wilfred Hughes's user avatar
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 ...
genehack's user avatar
  • 481
11 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 on: (setq isearch-lazy-count t) To compare with anzu, the count is shows in the minibuffer prompt, rather than the modeline. See the ...
bnzmnzhnz's user avatar
  • 111
11 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 ...
glucas's user avatar
  • 20.6k
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. ...
Yuri Steinschreiber's user avatar
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. ...
Basil's user avatar
  • 12.5k
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 ...
Maxim Kim's user avatar
  • 1,766
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 ...
chen bin's user avatar
  • 4,877
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 ...
abo-abo's user avatar
  • 14.2k
8 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. ...
Tobias's user avatar
  • 33.3k
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's user avatar
  • 33.1k
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 ...
NickD's user avatar
  • 30.9k
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-...
npostavs's user avatar
  • 9,213
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.
Xah Lee's user avatar
  • 1,766
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 ...
glucas's user avatar
  • 20.6k
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 ...
Drew's user avatar
  • 78k
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
xuchunyang's user avatar
  • 14.6k
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)
Jeeves's user avatar
  • 619
6 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.
sds's user avatar
  • 6,124
5 votes

Elisp search and delete

Search and replace already exists in Emacs! C-M-% ^.*?[0-9]:.*?seconds RET RET . C-M-% invokes query-replace-regexp. You enter a regular expression, then the replacement text (empty). The final . ...
Gilles 'SO- stop being evil''s user avatar
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 ...
giordano's user avatar
  • 3,255
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 ...
Omar's user avatar
  • 4,842
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-...
François Févotte's user avatar
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: (...
amitp's user avatar
  • 2,541
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 ...
zck's user avatar
  • 9,112
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 ...
Drew's user avatar
  • 78k
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 ...
Hubisan's user avatar
  • 1,745
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 ...
Muihlinn's user avatar
  • 2,644
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 ...
Tyler's user avatar
  • 22.4k

Only top scored, non community-wiki answers of a minimum length are eligible