简体   繁体   中英

What is the key binding to enter input string in C-s or C-r in Emacs?

In finding string in the current buffer, I know that we can use Cs or Cr, then you'll have the minibuffer prompt of what the string to be search. I know that we can use Mp or Mn to go to that prompt, but unfortunately emacs will display the previous search query.

I don't like using backspace to delete it, is there any key in which the prompt can be cleared from previous searches? Thanks

Are you saying you want to change your search term while you are already in the process of searching?

A couple of simple options are:

  1. Break out of the search first. I usually just do something which moves point, such as Ca . Then when you Cs again, the prompt will be blank (unless you type it twice, in which case it will search for the previous pattern again).

    RET is isearch-exit , but that has a different effect with no pattern, and I prefer the consistency. You could also use Cg ( isearch-abort ), but you may need to type that repeatedly, depending on what happened up to that point.

    ESC ESC ESC runs isearch-cancel which will reliably "Terminate the search and go back to the starting point", which may sometimes be preferable to Ca which will leave you on the line where you typed it.

  2. You can edit the pattern on the fly with Me , and then delete the whole thing with normal editing commands. After editing, type RET to continue searching for your newly-edited pattern.

Type Cs Ch Ch for the built-in help.

Try binding a key to the Mx search-forward command.

(global-set-key (kbd "Cs") 'search-forward)

This will automatically focus on the minibuffer and clear previous input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM