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.
精彩评论