Skip to content

Instantly share code, notes, and snippets.

@ageekymonk
Created February 8, 2012 06:42
Show Gist options
  • Save ageekymonk/1766121 to your computer and use it in GitHub Desktop.
Save ageekymonk/1766121 to your computer and use it in GitHub Desktop.
Highlight the current word in buffer. Similar to F8 highlight in Source Insight.
;; Shift F8 will highlight all the words that match underlying word in the buffer
(defun is-word-highlighted ()
(interactive)
(let ((face (or (get-char-property (point) 'read-face-name)
(get-char-property (point) 'face))))
(if (facep face) (if (face-equal face "hi-yellow") t nil) nil)))
(defun toggle-highlight-word ()
(interactive)
(setq sym (concat "\\<" (current-word) "\\>"))
(if (is-word-highlighted) (unhighlight-regexp sym) (highlight-regexp sym))
)
(global-set-key [S-f8] 'toggle-highlight-word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment