如何在python模式下自定义emacs以突出显示运算符?
我正在将 emacs 设置为我的 python IDE,并且我在网上找到了大量解释自动完成以及各种其他功能的材料。但我不明白的是如何让语法突出显示在运算符上发挥突出显示的魔力。
如何在 python 模式下自定义 emacs 以制作 + - 不同的颜色?我还希望它能够使整数、浮点数和括号具有不同的颜色。
I'm setting up emacs to be my python IDE, and I've found plenty of material online that explain auto-completion, among a variety of other features. What I can't figure out, though, is how to get the syntax highlighter to do its highlighting magic on operators.
How can I customize my emacs in python mode to make + - different colors? I'd also like it to make integers, floats, and parentheses different colors as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的编程模式实际上有类似的设置。这定义了 2 个独立的面,一个用于运算符,一个用于“结束语句”符号(显然在 python 中不太有用)。您可以修改
"\\([][|!.+=&/%*,<>(){}:^~-]+\\)"
正则表达式以匹配您感兴趣的运算符并将面孔自定义为您想要的颜色。然后,您只需通过向相关模式添加挂钩来启用此功能(此示例假设您正在使用“python-mode”):
i actually have something like this setup for my programming modes. this defines 2 separate faces, one for operators and one for the "end statement" symbol (not so useful in python, obviously). you can modify the
"\\([][|!.+=&/%*,<>(){}:^~-]+\\)"
regex to match the operators you are interested in and customize the faces to be the color you want.then, you just enable this by adding a hook to the relevant modes (this example assumes you are using "python-mode"):
将以下内容放入 ~/.emacs 文件中:
Put the following in your ~/.emacs file:
添加我自己的答案,因为我无法让其他人工作(截至 emacs 25.3.1,2017)。
以下 elisp 可用于突出显示运算符:
Adding my own answer since I couldn't get the others working (as of emacs 25.3.1, 2017).
The following elisp can be used to highlight operators: