在emacs中着色文本片段(Colorize snippets of text in emacs)

编程入门 行业动态 更新时间:2024-10-25 06:32:01
在emacs中着色文本片段(Colorize snippets of text in emacs)

假设我想强调一些单词,所以我想将这几个单词的颜色改为绿色。

有没有一种简单的方法在emacs中执行此操作?

谢谢。

Suppose I have a few words I would like to highlight, so I want to change the color of those few words only to, say, green.

Is there an easy way to do this in emacs?

Thank you.

最满意答案

这就是我所做的,使用font-lock-add-keywords 。 我想在我的代码中突出显示TODO: , HACK:和FIXME:这两个词。

(defface todo-face '((t ())) "Face for highlighting comments like TODO: and HACK:") (set-face-background 'todo-face cyan-name) ;; Add keywords we want highlighted (defun add-todo-to-current-mode () (font-lock-add-keywords nil '(("\\(TODO\\|HACK\\|FIXME\\):" 1 'todo-face prepend)) t))

This is what I've done, using font-lock-add-keywords. I wanted to highlight the words TODO:, HACK:, and FIXME: in my code.

(defface todo-face '((t ())) "Face for highlighting comments like TODO: and HACK:") (set-face-background 'todo-face cyan-name) ;; Add keywords we want highlighted (defun add-todo-to-current-mode () (font-lock-add-keywords nil '(("\\(TODO\\|HACK\\|FIXME\\):" 1 'todo-face prepend)) t))

更多推荐

本文发布于:2023-07-19 20:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186748.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:片段   文本   emacs   text   snippets

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!