I used Visual C++ for a number of years and loved the simplicity of the search. C-F3 brings the word under the cursor into the clipboard and does a forward search. Then F3 moves forwards through the search results while Shift-F3 goes back.
A similar feature in Vim I used to love is the asterisk * does the same thing as C-F3.
When I moved to Emacs, I hated the incremental search which forced me to to type the current word again. But now that I know the power of Emacs, I figured out how to fix this myself. Hurray!
Here is my rendition of this behavior which goes in the .emacs or init.el file.
(setq my-search-wrap nil) (defun my-search-func (dir) (interactive) (let* ((text (car search-ring)) newpoint) (when my-search-wrap (goto-char (if (= dir 1) (point-min) (point-max))) (setq my-search-wrap nil)) (setq newpoint (search-forward text nil t dir)) (if newpoint (set-mark (if (= dir 1) (- newpoint (length text)) (+ newpoint (length text)))) (message "Search Failed: %s" text) (ding) (setq my-search-wrap "some") ))) (defun my-search-fwd () (interactive) (my-search-func 1)) (defun my-search-bwd () (interactive) (my-search-func -1)) (defun yank-thing-into-search () (interactive) (let ((text (if mark-active (buffer-substring-no-properties (region-beginning)(region-end)) (or (current-word) "")))) (when (> (length text) 0) (isearch-update-ring text) (setq my-search-wrap nil) (my-search-fwd)))) (global-set-key (kbd "<f3>") 'my-search-fwd) (global-set-key (kbd "<S-f3>") 'my-search-bwd) (global-set-key (kbd "<C-f3>") 'yank-thing-into-search)
January 19, 2009 at 12:14 am
If you press C-w in isearch it will pick up the word under cursor. If you press C-s in isearch without typing anything it will use the last search string.
January 19, 2009 at 4:42 am
igrek: C-s C-w only selects the rest of the word. Most of the time, I find myself in the middle of the word and for C-w to select the whole-word under cursor, I need to move the cursor back to the beginning of the word.