gpt4 book ai didi

emacs python 模式 : how to highlight in different colors a str vs. unicode str

转载 作者:行者123 更新时间:2023-12-01 02:40:13 25 4
gpt4 key购买 nike

我希望 emacs 帮助我直观地识别尚未更改为 unicode 字符串的字符串(python 版本 < 3):

"display this string in color red"


u"display this string in color orange"

使用 emacs 23 和 python 模式

我需要向我的 .emacs 添加什么?谢谢。

最佳答案

我在 .emacs 中有类似以下内容:

(eval-after-load "python-mode"
(add-hook 'python-mode-hook
(lambda ()
(font-lock-add-keywords nil
'(("[^\\w]\\(r\\|u\\)[\'\"]" (1 font-lock-keyword-face)))))))

突出显示 'u' 本身(和 'r'),而不是整个字符串。也许这已经足够了,或者您可以找到一种方法来适应它。

关于emacs python 模式 : how to highlight in different colors a str vs. unicode str,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8664061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com