开发者

How to bind 'search' and 'search-repeat' to C-f in Emacs?

开发者 https://www.devze.com 2023-04-05 05:20 出处:网络
How can I to remap incremental search (C-s) to C-f in Emacs? I try to do (global-set-key (kbd \"C-f\") \'isearch-forward) but the second C-f does not repeat the search and I need to use C-s.

How can I to remap incremental search (C-s) to C-f in Emacs?

I try to do (global-set-key (kbd "C-f") 'isearch-forward) but the second C-f does not repeat the search and I need to use C-s.

I then tried (global-set-key (kbd "C-f") 'isearch-repeat-forward) but the first C-f didn't start the search.

And I even tried (global-set-key (kbd "C-f C-f") 'isearch-repeat-forward), but this causes an error.

I want to use C-f for search and search-repeat commands, h开发者_如何转开发ow can I do this?

Thanks.


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


isearch-repeat-forward is defined in the isearch-mode-map

To resolve your problem do the following :

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

(add-hook 'isearch-mode-hook
 (lambda ()
 (define-key isearch-mode-map (kbd "C-f") 'isearch-repeat-forward)
 )
)

EDIT: actually, you don't need to add a hook. The accepted answer by Ross Patterson is correct.

0

精彩评论

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