Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs key binding for isearch-forward

Tags:

emacs

I'm using Emacs v24.3 on Windows 7. I'm trying to learn how to remap key bindings.

I've created an .emacs file in my home directory and it contains one line:

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

I start up Emacs with runemacs.exe. I find a non-existant file, type some words (click at the start of the text) and type C-F to find. The I-search: prompt displays and I can incrementally search for text. So far so go.

The problem is, if the behavior is suppose be the same as the default isearch-forward keystroke, C-s, it isn't. When I type C-f a second time to search for the next occurance of the string, the only thing that happens is the I-search prompt appears in the minibuffer.

I'm not able to search for the next occurance of the string. Additionally, the Del key is suppose to repeate the search in the reverse direction. That does not happen for me when I search using C-f (though it does when I search using C-s.).

So this single key mapping seems to break two things. Am I mapping wrong? Or are these bugs? If I'm mapping wrong, how do I map C-f to the isearch-forward command?

like image 530
Karl Avatar asked Aug 10 '13 00:08

Karl


1 Answers

Along with your one line, add:

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

The issue is that isearch has its own bindings that are active once you start an incremental search. Adding the expression above remaps the binding for isearch-repeat-forward.

If you're curious about these bindings, you can enter C-h b while doing an incremental search to examine the full keymap.

like image 197
Keith Flower Avatar answered Sep 21 '22 07:09

Keith Flower