In Vim the * key in normal mode searches for the word under the cursor. In GNU Emacs the closest native equivalent would be:
C-s C-w
But th
;Here is my version: Emulates Visual Studio/Windows key bindings
; C-F3 - Start searching the word at the point
; F3 searches forward and Shift F3 goes reverse
(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 text))))
(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 "") 'my-search-fwd) ; Visual Studio like search keys
(global-set-key (kbd "") 'my-search-bwd)
(global-set-key (kbd "") 'yank-thing-into-search)