Questions tagged [search]

Questions about search mechanics inside of Emacs.

Filter by
Sorted by
Tagged with
55 votes
9 answers
13k views

How do I find text across many open buffers?

Lets say I have 10 buffers open, and I want to find all occurrences of blah in all 10 buffers. How would I do this?
nixeagle's user avatar
  • 2,457
40 votes
5 answers
25k views

What is the easiest way to search all useful files inside a single project?

What is the easiest way to search for a regexp throughout the contents all files in the current project, skipping files that are not useful? Useless files are things like compiled files, imported ...
Malabarba's user avatar
  • 23.2k
29 votes
3 answers
4k views

Match two spaces with incremental search

When searching using: C-s SPC SPC Also matches single spaces. I want to match exactly two space.
Rovanion's user avatar
  • 987
27 votes
2 answers
5k views

Counsel M-x always shows "^"

I installed Counsel/Ivy/Swiper and so far everything works fine. But when I call counsel-M-x via key bind M-x an "^" char is always added. I have no clue why this is happening and how to get rid of it ...
dmw's user avatar
  • 373
23 votes
6 answers
5k views

Getting number of occurrences, during incremental search (C-s / isearch-forward)

Inspired by modern browsers, I'd love to be able to see how many occurrences there are of some string, when I search for it – like the "10 of 37" at the top-right corner of the screenshot below. ...
ShreevatsaR's user avatar
21 votes
2 answers
5k views

Only show lines containing phrase/regex

I would like to see all the lines from the current buffer, that contain some phrase, or match regex. Example: My buffer: dam madam madam this is da m a dam 1 dam 2 dam pi dam 321:) is dam 2? ...
MatthewRock's user avatar
  • 1,483
13 votes
7 answers
2k views

How to search the Emacs Lisp Reference Manual?

Sometimes describe- or apropos- are not enough. How can I search the Emacs Lisp Reference Manual (C-h i m elisp) from within emacs?
caisah's user avatar
  • 4,096
13 votes
1 answer
814 views

Search for string ignoring new lines

I am used to writing files where paragraphs are split into several lines, e.g. with fill-column. When I search for a string (C-s) such as this is a long text, the search results would not return the ...
Tony's user avatar
  • 231
12 votes
2 answers
5k views

Helm: search within buffer feature?

A pretty basic Helm question. What is the Helm window/command/feature that lets us search for text (preferably using regexp) within any type of buffer (i.e., including read-only such as w3m)? In ...
iceman's user avatar
  • 1,088
11 votes
4 answers
143 views

How to convert a series of lines into a working HTML list?

Right now, this is a task I find a lot easier in something like gedit, because I can just replace "\n" (the line break) with "</li>\n<li>" and then I have a list. One of the few little ...
mattl's user avatar
  • 215
11 votes
4 answers
5k views

How to search in multiple files with Emacs without grep?

There is a folder with many sub-folders, files and I would like to search for a given piece of text in all of these files with Emacs on a Windows 10 machine. (I know about M-x grep, but it does not ...
user avatar
11 votes
2 answers
2k views

Search through the values of all variables in Emacs

I'd like to find which variables contain a certain value. Is there a way to do a regex search through the values of every variable in Emacs?
izkon's user avatar
  • 1,878
11 votes
4 answers
2k views

helm-ag (or similar) find in javascript files only

I'd like to restrict find/grep to (say) only javascript files (mainly because that's what i do in "another editor"). Javascript files in my legacy Ruby-on-Rails project have one of these file ...
mustISignUp's user avatar
10 votes
1 answer
3k views

How to search an Arabic word in text without its diacritics/accents?

In Arabic as with some other languages there is what is called diacritics to enhance pronunciation. There is no convention on how many diacritics should be written for a single word. Some use the ...
doctorate's user avatar
  • 1,829
9 votes
2 answers
335 views

Does "Occur-at-point" already exist?

I wrote an elisp function for myself at the weekend: (defun rr-occur () ...
Realraptor's user avatar
  • 1,293
9 votes
3 answers
6k views

Recursively find all files from a folder containing a regexp in the filename, using helm

How can I find all files from a folder and its subfolders recursively, containing a regexp in the filename, using helm? For example: how to search for all files with the extension .el and containing ...
caisah's user avatar
  • 4,096
9 votes
2 answers
839 views

Selecting (i.e., as the region) the current match in incremental search

When searching for a string with C-s, I want to be able to hit some key to exit search mode but still maintain the selection of the match. That way I can immediately start typing and replace the last ...
Ben's user avatar
  • 607
9 votes
3 answers
2k views

how do I do case sensitive searches using evil/spacemacs?

I'm trying to perform a search and replace in spacemacs but I need it to be case sensitive when by default it appears to be case insensitive. So I try to do :set noignorecase but then I have this ...
ChiseledAbs's user avatar
9 votes
1 answer
246 views

Query search and comment out line?

I am hoping to figure out how to do a query search that will comment out a line instead of query replace. That is, do an interactive query search, and if I say yes, comment out the line the match is ...
Jaime Arturo Gomez's user avatar
8 votes
5 answers
2k views

How do I search in search results

When I C-s I can search. How should I do a function which I could bind for example to C-r which would let me search in the results of some predefined search query? Like contents of window would be: ...
lukas.pukenis's user avatar
8 votes
2 answers
2k views

How to search *just* the current line

I'm working with large, extra wide data files I probably should just be viewing in Excel... but I'd rather stay in Emacs. Is there an elisp function to search (and fontify) just on the current line?
wdkrnls's user avatar
  • 3,707
8 votes
3 answers
1k views

How to center the current line vertically during Isearch

During search and especially search-and-replace it would be nice to have the surrounding lines as context. But when jumping to the next hit, the cursor sometimes ends at the lowest visible line (or ...
Beginner's user avatar
  • 2,721
8 votes
3 answers
870 views

Search and replace through a multifile project in AUCTeX?

I am about to adopt Emacs to be the only editor I use in all what I am writing including LaTeX documents. I came from WYSIWYG editor which served that purpose fairly nice, namely TexStudio or TXS for ...
doctorate's user avatar
  • 1,829
8 votes
1 answer
2k views

Difference between `evil-search-forward` and `evil-ex-search-forward`

It's in the title: What's the difference between evil-search-forward and evil-ex-search-forward? When would I want to use one instead of the other? evil-search-forward Search forward for user-...
digitalis_'s user avatar
8 votes
2 answers
1k views

How to check if a string exists in the current buffer?

I want to know how do you use Emacs lisp to check the content of the current buffer, specially to know if certain string exists within the current buffer.
shackra's user avatar
  • 2,782
8 votes
3 answers
1k views

Highlighting text in open (displayed) buffers/windows -- searching for text from one buffer in another

Right now, I have my Emacs frame vertically split, and am looking at two different buffers in the two windows. I'd like to go to a word in one buffer, hit some keys, and have the ocurrences of that ...
ShreevatsaR's user avatar
8 votes
2 answers
1k views

How to search for a sequence of bytes in hexl-mode?

Is it possible to search for a byte sequence in hexl-mode and possibly highlight it? E.g. in the file below I want to search the byte sequence f9beb4d9. isearch does not work because it searches the ...
gdkrmr's user avatar
  • 205
7 votes
2 answers
363 views

When to use normal incremental search in place of the regex version?

Assuming familiarity with regex, is there ever any reason to use the normal incremental search (C-s) over regex (C-M-s)?
Jessie's user avatar
  • 327
7 votes
1 answer
260 views

Is there a more efficient alternative to search-forward when searching for a single character?

I need to split the contents of a buffer into a list of strings. The null character is used to separate the items. It the items were separated by newline characters, then I could use the same ...
tarsius's user avatar
  • 25.7k
7 votes
3 answers
150 views

`query-replace` leaves potential match to be replaced at bottom of window

If I have a long document that I run query-replace (or any other number of commands) in, as I'm saying y or n to replace that match or not, the current potential item to be replaced is always at the ...
Chris Poole's user avatar
7 votes
1 answer
365 views

edit search string and begin search from current location

I use C-s to start an incremental search. Sometimes I want to change the search string and either restart the search entirely from the beginning of the document or (other times) just change the search ...
Alex's user avatar
  • 173
7 votes
2 answers
119 views

When searching, how to always ensure that a few lines after the highlighted word are visible?

When performing search/isearch in a text, sometimes it would be desirable to see a few lines after the highlighted searched string, it other words to avoid that the highlighted word to be at the ...
Name's user avatar
  • 7,859
7 votes
3 answers
2k views

How to search for lines not containing some text?

In a large file, I want to find which lines which do not contain a given string, grep -v basically. M-x grep helps, but it forces to protect special characters, is not interactive nor incremental, ...
Nikana Reklawyks's user avatar
6 votes
3 answers
2k views

Is it possible to insert word at point in swiper?

I'm using swiper for searching, one thing i very much miss compared to isearch is to insert the word at point into swiper. I have icicles installed, but M-., which i usally use to insert word at point ...
BMBM's user avatar
  • 361
6 votes
2 answers
2k views

Swiper get last search term

How to get swiper to search for the last searched term , much like (default) isearch-forward does when pressing C-s twice?
yPhil's user avatar
  • 983
6 votes
4 answers
2k views

Ringing Bell in Macro with Search

It throws the error After 0 kbd macro iterations: isearch-search: Keyboard macro terminated by a command ringing the bell and I have no idea why, nor can I find anything about it by searching. Any ...
Aido's user avatar
  • 175
6 votes
1 answer
2k views

How to search by tags in org-mode

Here is a simple file: #+TAGS: math(m) music(u) * Gödel :math: * Bach :music: * Gauss :math: * Beethoven :music: * Mozart :music: Then I tried M-x org-tags-view Match: +math I expected that Gödel ...
user4035's user avatar
  • 1,059
6 votes
1 answer
537 views

Preset search isearch-string from command line

I am trying to set isearch-string from the command line. The purpose is to have a Perl script start Emacs with a given search string, and go directly to the first line of the string and enter search ...
Håkon Hægland's user avatar
6 votes
2 answers
455 views

How to search/isearch just comments?

Is it possible to perform a search/isearch just in comment regions of the text?
Name's user avatar
  • 7,859
5 votes
3 answers
9k views

Search for text and navigate between the occurrences

I want to be able to search for some text and navigate quickly between the occurrences. What is a convenient way to search for some text, view all the occurrences, and jump quickly to the next/...
programking's user avatar
  • 7,194
5 votes
1 answer
926 views

Gracefully Exiting a While Loop

So, I have this function, which works just fine for me and does what I want it to: (defun mwp-set-grade () (interactive) (save-excursion (while (re-search-forward "- Grade :: \\\(.*\\...
Matt's user avatar
  • 115
5 votes
2 answers
276 views

Incremental Search after opening file

Being fairly new to GNU Emacs and intend to use it as a replacement to vi/vim where possible, I came across an obstacle, I seem not be able to overcome. In vim (similar to less) you can provide a ...
Phoenix's user avatar
  • 351
5 votes
2 answers
2k views

in Emacs regex, how to search for uppercase letters only?

I'm trying to build a function but having trouble with the regex. Specifically, I want to match capital letters only. This function is supposed to capitalize words that are in lowercase (the → The) ...
incandescentman's user avatar
5 votes
1 answer
475 views

Search and replace with case preservation and plurals

Is there a way (or package) to search and replace code like: class Account def list_accounts end end to class Company def list_companies end end Basically I want to replace account(s) with ...
Cezar Halmagean's user avatar
5 votes
2 answers
1k views

Display search results in their own buffer

I've use helm and ivy with swiper the search is great but I like to be able to keep search results in a buffer, navigate and edit my code and switch back to my search results buffer.
luxcem's user avatar
  • 151
5 votes
1 answer
1k views

How to jump up or down to first non-whitespace character in same column

I use evil-mode with Emacs and would like to accomplish this via evil-mode, but would be fine with doing it in an Emacs-centric way too. The subject line explains it well, but here is a post in which ...
Joe's user avatar
  • 571
5 votes
3 answers
602 views

How to use helm to complete sources which are lines in a buffer?

I have a buffer (not a file) containing data. I would like a function that lets the user select 1 or more lines of this buffer, e.g., by typing a regexp, and that returns the result as a list of ...
Damien Cassou's user avatar
5 votes
2 answers
261 views

Hyperlinked code navigation

I'd like to browse source code in emacs by searching for 'word' or 'tag' hits in a way somewhat similar to etags but: clicking on words to search for matches across a code base (say a directory or ...
Croad Langshan's user avatar
4 votes
2 answers
3k views

how to search and replace an entire word?

I know the command isearch-forward-word, but there doesn't seem to be an isearch-replace-word. I'd like to search and replace every instance of a certain word in a buffer. For instance, search for ...
incandescentman's user avatar
4 votes
3 answers
2k views

Search for and correct capitalized words that are not at the beginning of a sentence

I have a latex document in which there are many incorrectly Capitalized words. Could anybody suggest a clever regex to track them? Even better if there is a function which cycles through such words ...
kindahero's user avatar
  • 548

1
2 3 4 5
7