I'm a vim user and have recently been trying out emacs for fun. I find that the feature I'm missing most so far from vim is the "super star" (find the word under the cursor by typing *) feature, and I have yet to find the equivalent in emacs. If it's not built in, what would I need to add to my emacs file to get something similar?
+6
A:
Here is a start:
(global-set-key (kbd "C-*") (lambda () (interactive) (re-search-forward (format "\\b%s\\b" (thing-at-point 'word)))))
huaiyuan
2009-11-21 10:02:30
+2
A:
Usually, I just do (M-b …) C-s C-w … C-s. That is:
- M-b to move to beginning of word(s) of interest
- zero or more of these
- C-s to start an I-Search
- C-w to yank the word(s) starting at point
- one or more of these
- C-s to find the next match
- more C-s to find later matches
- RET to exit the I-search at the most recent match
- or a bunch of C-g to abort back to the original starting location
Here is a go at integrating it into I-Search (C-s and C-r; use C-h k C-s for info on the isearch).
(require "thingatpt")
(require "isearch")
(define-key isearch-mode-map (kbd "C-*")
(lambda ()
"Reset current isearch to a word-mode search of the word under point."
(interactive)
(setq isearch-word t
isearch-string ""
isearch-message "")
(isearch-yank-string (word-at-point))))
Integrating it into I-Search, takes advantage of its word matching and case sensitivity settings (C-s M-c C-* would do a case-sensitive search on the word under the point).
Chris Johnsen
2009-11-21 11:10:31
+4
A:
Duplicate question:
http://stackoverflow.com/questions/589691/how-can-i-emulate-vims-search-in-gnu-emacs
scottfrazer
2009-11-21 13:04:19
I knew this had to be answered before, but my search skills just weren't turning anything up. I tried searching for terms like equivalent, vim, emacs, super star, etc. Out of curiosity, if you remember, what search led you to find this answer?
mmrobins
2009-11-21 17:17:53
I was the one who wrote the answer :)
scottfrazer
2009-11-21 19:05:54
That makes a lot of sense :)
mmrobins
2009-11-23 01:37:32