4

This might be a trivial issue, but here goes:

I like to search (C-s or M-C-s for regexp search) often, and I want to be able to search in the buffer I'm in - jumping up and down (C-r, C-s) between the results found, but I also want an easy way to get back to the minibuffer to edit the search and start over again.

What's the easiest way to do this without having to use the mouse to click the minibuffer and edit the search query term? Ideally, I'd have some key-combination that takes me back to the minibuffer to edit the search, and then the standard C-s to start the search results again.

Right now, I'm doing:

  1. Trigger search: C-s or M-C-s.
  2. Type query, C-s and jump through results. Notice that I should search for something similar but different (ie- I need to edit my current search term).
  3. C-f to get out of searching (just so I can go back to searching again).
  4. C-s to search again, M-p to pull the last result, edit and C-s again.

I'd love a way to short-circuit steps 3 & 4. All in an effort to not use the mouse.

2 Answers 2

7

You can hit M-e to edit the current search term. This runs the command isearch-edit-string. You can then type C-s to resume the search.

To get a list of all key bindings available during isearch, type C-s (to enter isearch) and then C-h b. You can also get some documentation by typing C-s C-h m (describe-mode). Here's some basic key bindings from that documentation:

DEL:       cancel last input item from end of search string.
RET:       exit, leaving point at location found.
LFD (C-j): to match end of line.
C-s:       search again forward, C-r to search again backward.
C-w:       yank next word or character in buffer onto the end of the search
    string, and search for it.
C-M-w:     delete character from end of search string.
C-M-y:     yank char from buffer onto end of search string and search for it.
M-s C-e:   yank rest of line onto end of search string and search for it.
C-y:       yank the last string of killed text.
M-y:       replace string just yanked into search prompt with string killed
    before it.
C-q:       quote control character to search for it.
C-x 8 RET: add a character to search by Unicode name, with completion.
C-g:       while searching or when search has failed cancels input back to what
    has been found successfully.

C-g:       when search is successful aborts and moves point to starting point.

As aside, please note that isearch does not actually use the minibuffer; it only appears to. It actually uses the echo area.

0
1

@Nanny's answer tells you about editing the search string and then resuming searching with the edited string.

Your question is not too clear to me, but here is some other info about ways to temporarily stopping your current search, doing something else, and then resuming that search. Perhaps it is relevant to what you are trying to do and will help.

  • You can use M-p and M-n to cycle to previously used search strings. So you can search for foo, bouncing around looking at its search hits, and then use M-p (repeat to get to older search strings) to retrieve a previous search string and search for that.

  • If you just want to be able to scroll past the current set of highlighted search hits, and then come back and resume where you left off, you can do that by setting option isearch-allow-scroll to non-nil.

  • If you use library Isearch+ then you can use C-x o while searching, to enter a recursive edit. In the recursive edit you can do anything you like (you have left Isearch), including search for something else. You end the recursive edit using C-].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.