13
votes
Search for string ignoring new lines
Take a look at the variables isearch-lax-whitespace, isearch-regexp-lax-whitespace, and search-whitespace-regexp.
If the first two variables are set to something non-nil (e.g. t) any space character ...
13
votes
Accepted
Delete portion of Isearch string that does not match, or last char if complete match
Ah yes. Isearch reads the keys you type, looks them up in isearch-mode-map, and invokes them in the current buffer.
Isearch does not, in spite of appearances, use the minibuffer. It uses the echo ...
12
votes
Make isearch skip folded content in org-mode
You can set search-invisible to nil in your .emacs or using Customize. Then, if you do want to show matches in invisible text, press M-s i while using isearch.
(I found this by reading the docs of ...
9
votes
Accepted
how to search and replace an entire word?
You don't need to define a separate function (command) for this. And even if you did define one, it need not use query-replace-regexp.
The standard command query-replace does just what you request, ...
8
votes
How can I match "snake_case" automatically when I search for "snake-case" by mistake?
I can't imagine any such automated behaviour not then causing you pain when that's not what you wanted it to do.
To my mind kaushalmodi's recommendation of M-e is the best answer -- making it easy to ...
8
votes
Scrolling during isearch stops searching, losing matches
@legosia's answer is the usual one, and probably what you want. But be aware that there is an alternative Isearch behavior that lets you scroll the buffer being searched without exiting Isearch.
If ...
7
votes
Make isearch skip folded content in org-mode
While using isearch you can toggle the search on invisible text with M-s i.
You can also customize this behaviour with M-x customize-group isearch and searching for Search Invisible.
Note that this ...
7
votes
Accepted
Use thing-at-point for isearch and minibuffer commands
If you use library Icicles then you can use M-. at any time from the minibuffer to insert a thing-at-point from the buffer.
You can repeat M-. to either (a) append subsequent such things from the ...
7
votes
Accepted
When to use normal incremental search in place of the regex version?
Yes: if you want to search for a literal string, but that string contains special regex characters, it'll require extra escaping on your part.
Example text to search: "some*text"
C-s some*text ...

Dan♦
- 31k
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
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 ...
6
votes
Accepted
How to combine the history of isearch and query-replace?
Customize option query-replace-from-history-variable (or query-replace-to-history-variable, or both). Point to search-ring or regexp-search-ring instead of query-replace-history.
6
votes
Accepted
Search and replace invisible url link in org-mode
Try M-x org-toggle-link-display or the menu item Org -> Hyperlinks -> Literal Links before using isearch or query-replace.
The following code does that automagically for you when you use ...
6
votes
Accepted
Search for either of two words using isearch
C-M-s to invoke isearch-forward-regexp then type aaa\|bbb, where aaa is your first word and bbb is your second.
Alternatives, just C-s to invoke isearch, then press M-r to toggle to regex.
6
votes
char-fold-search match for German eszett (ß)?
By default, this is not possible (easiest way to see this is with C-h v char-fold-table RET and searching for ß — which you won't find).
However, if you modify char-fold-table (the variable ...
6
votes
Accepted
Extending word search selection in swiper
Try M-j, which is bound to ivy-yank-word in the ivy minibuffer key map.
It's worth reading through the the ivy manual, either in Emacs or online. The relevant key bindings are discussed here: http://...
5
votes
How to search an Arabic word in text without its diacritics/accents?
Here's a rough start, based on the list of combining characters in this answer (and then extended). (Marking this as community wiki — please edit and improve this!)
(defconst arabic-diacritics '(#...
Community wiki
5
votes
Accepted
When searching, how to always ensure that a few lines after the highlighted word are visible?
(setq scroll-margin 3)
Works everywhere, not just during isearch.
scroll-margin. Default: 0. Number of lines of margin at the top and bottom of a window.
Recenter the window whenever point gets ...
5
votes
Accepted
How to use backspace to erase last character in search string?
You'll want to change
(global-set-key (kbd "<backspace>") 'delete-backward-char)
either to
(global-set-key (kbd "DEL") 'delete-backward-char)
or to nothing at all. The definition you use ...
5
votes
How can I match "snake_case" automatically when I search for "snake-case" by mistake?
If you use swiper and search for snake case, it will match
both snake_case and snake-case.
swiper is a new isearch alternative that gives you an overview in the minibuffer as you search.
In the ...
5
votes
Accepted
Quick access to the previous search terms after calling isearch-forward without switching to the minibuffer
With C-s C-s you search the previous word. Then M-p (and M-n) for history.
5
votes
Accepted
isearch but don't move the cursor until I ask to search
C-g, possibly repeating it, puts you back where you started and exits Isearch.
Not wanting search to start until you've finished typing is not incremental search. It is plain, nonincremental search....
5
votes
Accepted
Move cursor left/right while entering isearch
You can run the command isearch-edit-string pressing M-e. See the documentation for details.
5
votes
Accepted
Wraparound search with `isearch-mode`
It works OK for me. Did you use C-s to repeat the search?
C-s repeats Isearch, including to wrap around.
You can replace the repeat-search binding:
(define-key isearch-mode-map (kbd "<C-f3>") ...
5
votes
Accepted
Non-greedy regex not working
The problem is not about using non-greedy matching. It is about which chars you're matching. Specifically, you want to match 《 followed by any number of non-《 chars, followed by IJ》.
This is a ...
4
votes
Accepted
Ringing Bell in Macro with Search
According to Emacs Wiki, you can't use isearch during a keyboard macro.
http://www.emacswiki.org/emacs/KeyboardMacros#toc2
4
votes
Accepted
How can I configure incremental search to put my cursor at the start of whitespace rather than the end?
The Emacs Manual (section Special Isearch) says this:
By default, incremental search performs lax space matching: each space, or sequence of spaces, matches any sequence of one or more spaces in the ...
4
votes
Accepted
How to search/isearch just comments?
Yes. Use library Isearch+, specifically file isearch-prop.el.
As it says here:
You can search the text of THINGS of various kind (sexps, lists, defuns, lines, pages, sentences, filenames, strings, ...
4
votes
When to use normal incremental search in place of the regex version?
@Dan provided a good answer to the question. I will add this:
As @Adobe indicated in a comment, you can use M-r anytime during Isearch (literal search or regexp search) to toggle between regexp ...
4
votes
how to search and replace an entire word?
Run query-replace-regexp with '\bi\b' as the query and 'I' as the replacement.
(Update to comment)
The function @lawlist linked to should work nicely if you want to replace all instances without ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
isearch × 135search × 23
key-bindings × 9
regular-expressions × 9
org-mode × 7
minibuffer × 6
region × 6
text-properties × 6
replace × 5
highlighting × 5
whitespace × 5
keyboard-macros × 5
query-replace × 5
words × 5
latex × 4
faces × 3
keymap × 3
ivy × 3
scrolling × 3
history × 3
swiper × 3
case-folding × 3
auctex × 2
elisp × 2
completion × 2