How to cross out the lines "// comment" in Emacs?

Emacs regexp problem: how to highlight all lines starting with "//"?

I would like to denigrate my comments in text mode, but the following snippet does not work:

(add-hook 'text-mode-hook
(lambda()
  (font-lock-add-keywords nil
  '(("^//.+"
     1 font-lock-comment-face prepend)))))

"Re-builder" pointed out that this expression should do the trick. What's wrong? Thank!

+5
source share
2 answers

Ok, I figured it out. "^\\(//.*\\)$"performs the task.

Sorry for the possible spam. I did google almost two hours earlier; regular expressions seem much higher than my head.

+7
source

Since the regular expression matches everything that highlighting is applied to, there is an alternative method:

(add-hook 'text-mode-hook
(lambda()
  (font-lock-add-keywords nil
  '(("^//.+"
     0 font-lock-comment-face prepend)))))

0 , ( 1 ..)


, emacs, , , , , , , ( , , .) ++ - .

+3

All Articles