开发者

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 C-s or C-r, then you'll have the minibuffer prompt of what the string to be search. I know that we can use M-p or M-n 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 i开发者_C百科n 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 C-a. Then when you C-s 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 C-g (isearch-abort), but you may need to type that repeatedly, depending on what happened up to that point.

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

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

Type C-sC-hC-h for the built-in help.


Try binding a key to the M-x search-forward command.

(global-set-key (kbd "C-s") 'search-forward)

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜