Emacs isearch-forward的键绑定

时间:2013-08-10 00:52:04

标签: emacs

我在Windows 7上使用Emacs v24.3。我正在尝试学习如何重新映射键绑定。

我在我的主目录中创建了一个.emacs文件,它包含一行:

 (global-set-key (kbd "C-f") 'isearch-forward)

我用runemacs.exe启动Emacs。我找到一个不存在的文件,键入一些单词(单击文本的开头)并键入C-F进行查找。显示I-search:提示,我可以逐步搜索文本。到目前为止一切顺利。

问题是,如果行为与默认的isearch-forward击键C-s相同,则不是。{当我第二次键入C-f来搜索字符串的下一个出现时,唯一发生的事情是迷你缓冲区中出现I-search提示。

我无法搜索下一次出现的字符串。另外,Del密钥假设在相反方向上重复搜索。当我使用C-f进行搜索时,这种情况不会发生(尽管我使用C-s进行搜索时会这样做。)。

所以这个单键映射似乎打破了两件事。我映射错了吗?或者这些错误?如果我映射错误,如何将C-f映射到isearch-forward命令?

2 个答案:

答案 0 :(得分:11)

与您的一行一起添加:

(define-key isearch-mode-map "\C-f" 'isearch-repeat-forward)

问题是,一旦开始增量搜索,isearch就有自己的活动绑定。添加上面的表达式会重新映射isearch-repeat-forward的绑定。

如果您对这些绑定感到好奇,可以在进行增量搜索时输入 C-h b 来检查完整的键映射。

答案 1 :(得分:0)

不,我不认为教程会这么说。我想你指的是 SEARCHING 部分和本文:

>> Type C-s again, to search for the next occurrence of "cursor".
>> Now type `<DEL>` four times and see how the cursor moves.

If you are in the middle of an incremental search and type <DEL>, the
search "retreats" to an earlier location.  If you type <DEL> just
after you had typed C-s to advance to the next occurrence of a search
string, the <DEL> moves the cursor back to an earlier occurrence.  If
there are no earlier occurrences, the `<DEL>` erases the last character
in the search string.  For instance, suppose you have typed "c", to
search for the first occurrence of "c".  Now if you type "u", the
cursor will move to the first occurrence of "cu".  Now type <DEL>.
This erases the "u" from the search string, and the cursor moves back
to the first occurrence of "c".

<DEL>不向后搜索。它会从搜索中删除一个字符 字符串,搜索将移动到结果字符串的上一个匹配(仅限)。 但<DEL>之后的第一个C-s不会改变搜索字符串。它只是 移动到上一个命中(仅限)。

教程文本不正确,但可能有点困难 读。如果您有改进建议,或者只是想让Emacs Dev知道您发现它不清楚,请使用M-x report-emacs-bug