How can I jump to the next beginning of a string highlighted by a command such as highlight-regexp or highlight-lines-matching-regexp?

1 Answer 1


C-u C-s allows you to search for a regexp forward. C-s again recalls the last regexp used.

The following function finds the beginning of the next highlighted region. It prompts for a highlight color so that is not really comfortable. I know it but I do not know the exact circumstance you want to use it. You can easily improve it.

(defun beginning-of-next-highlighted-region (&optional hl)
 "Moves the point before the first following character  that highlighted with the HL highlight or at end of buffer"
  (interactive  (list  (hi-lock-read-face-name) ))
  (while(let ((fc (get-text-property (point)'face) ))
                  (and (consp fc )(memq hl fc) ))
  (while (let ((fc (get-text-property (point)'face) ))
                   (or (not (consp fc )) (not (memq hl fc))))

You can bind it at any key sequence you want

(bind-key (kbd "C-c h") #'beginning-of-next-highlighted-region)
  • 1
    This is a good idea but I was looking for a highlights-oriented solution to use in conjunction with, for instance, highlight-lines-matching-regexp. Jul 26, 2021 at 8:43
  • I composed a small function to do the trick.
    – gigiair
    Jul 26, 2021 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.