1

I am relatively new to emacs. I am looking for a way to do the "exact match" type of interactive search. For example, search string "abcDEF" in following text should only match with line1's text:

  • line1-> sometext_followed_by_space abcDEF sometext_preceded_by_space
  • line2-> sometext_followed_by_space .abcDEF sometext_preceded_by_space
  • line3-> sometext_followed_by_space abcdef sometext_preceded_by_space

1 Answer 1

3

You are apparently looking for word search with case-sensitivity.

For case-sensitive search, set case-fold-search to nil.

You can also just toggle case-sensitivity temporarily, during Isearch, using M-c.

For incremental word search, use M-s w. For nonincremental word search, use M-s w RET.

There are additional ways to do word search. See the Emacs manual, node Word Search.


Strike that, for you apparently do not want to find abcDEF when it follows .. So you want something different from word search.

In that case, use regexp search, looking for whitespace followed by word-constituent characters, e.g. C-M-s [[:space:]]abcDEF.


That includes the whitespace in the search hit. If you want to be able to see the word itself highlighted differently from the total match, use library isearch+.el and search with this: C-M-s [[:space:]]\(abcDEF\). Isearch+ highlights each regexp group (e.g. \(...\)) differently.

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.