I've a document I'm editing, were I want to search for the next occurrence of the last word that appears within a pair of hashes. Some examples would be:

 #word#, #x(anotherWord)#, #y(x(yetAnotherWord))# 

I want to ignore the surrounding functions and brackets.

I'm new to Vim key bindings and am not clear on how to do it either in evil or holy modes.

  • Please do not post your question to both SE.emacs and StackOverflow. Please delete one of the posts. Thx.
    – Drew
    Oct 11, 2017 at 23:10
  • Done. Sorry about that.
    – user619882
    Oct 12, 2017 at 9:25

1 Answer 1

/\b\w+\Sw*#[^#<C-q C-j>]*$<RET>

This should work in evil, whereby <C-q C-j> and <RET> are key-sequences.

Unless, what you really want to do is searching for symbols rather than words.

Here is an explanation of the regular-expression's components.

\b               ;beginning of a word
\w+              ;one or more word character
\Sw*             ;zero or more non-word character
#                ;a single '#' character
[^#<C-q C-j>]*   ;0 or more arbitrary character, except '#' and '\n'
$                ;end of line
  • Thank you --- that's some crazy Emac-fu. You're helped me a great deal.
    – user619882
    Oct 12, 2017 at 21:13

Your Answer

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

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