Emacs有highlight-thing
的插件,可以高亮当前光标下的内容。我曾经给LispWorks也写过一个类似的插件,但我当时写它的主要目的是为了能快速在重复的symbol间navigate,可highlight-thing
恰好缺少这个功能。受不了了,在highlight-thing
的基础上随便手搓了一个,有时间再优化吧。
若有重复或更好用的功能请务必指出,目前精神分裂发作期,逻辑不畅还请见谅。加载下面代码后,按C-<
光标移动到前一个symbol出现位置,C->
移动到后一个
(defun prev-thing ()
"Navigate to previous same thing.
Should be used together with `highlight-thing'"
(interactive)
(when-let (it (search-backward-regexp highlight-thing-last-regex nil t 1))
(goto-char it)))
(defun next-thing ()
"Navigate to next same things.
Should be used together with `highlight-thing'."
(interactive)
(when-let (it (search-forward-regexp highlight-thing-last-regex nil t 1))
(goto-char it)))
;; Recommend Binding
(global-set-key (kbd "C-<") 'prev-thing)
(global-set-key (kbd "C->") 'next-thing)
Happy Hacking!