2

For example, I got the following lines:

1. abc
2. abc def
3. abc_def
4. _abc
5. abc_

and I want to search only the word abc, so only the 1 and 2 lines matches, I googled a while, it says \babc\b would work, but it doesn't work for me, and I found that \_<abc\_> works.

But I want to make it work with helm-occur, such as when I use the regular helm-occur (I bound it to Ctrl-s), it should work as default helm-occur, but if I called it with a prefix argument (Ctrl-u), it will search the whole word instead of string on top of the helm-occur.

Is there anyone knowing how to do this?

1

Anyway, I found the solution from this page, not directly modify helm-occur but it is useful.

(defun helm-occur-insert-symbol-regexp ()
    (interactive)
    (helm-set-pattern (concat "\\_<" helm-input "\\_>")))
(define-key helm-moccur-map (kbd "<right>") 'helm-occur-insert-symbol-regexp)

Use <right> key to search the whole in helm-occur session. Better solutions are welcome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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