简体   繁体   English

如何在原子编辑器中更改TODO高亮显示

[英]How to change TODO highlight in atom editor

In my opinion the higlighting of a TODO "flag" in the atom editor is too weak/unobtrusively. 在我看来,原子编辑器中TODO“标志”的高亮显示太弱/不显眼。

How can I change this? 我怎么能改变这个? I DON'T wanna list the todos in a sidebar ( https://atom.io/packages/todo-show ). 我不想在侧栏中列出待办事项( https://atom.io/packages/todo-show )。

Here to compare: 在这里进行比较:

In Vim editor there is very strong highlighting (desired): 在Vim编辑器中有非常强烈的突出显示(所需): 在此输入图像描述

In Atom editor: 在Atom编辑器中: 在此输入图像描述

The main problem is, that atom highlights many other code words in this color... 主要问题是,该原子突出了这种颜色中的许多其他代码字...

As GitHub's Atom Editor is built around HTML5 and CSS3 you can very easily change your style sheet, I've done a little recording on how to make this specific change below although you can apply the same principals to any styled element within the editor: 由于GitHub的Atom编辑器是围绕HTML5和CSS3构建的,因此您可以非常轻松地更改样式表,我已经做了一些关于如何在下面进行此特定更改的记录,尽管您可以将相同的主体应用于编辑器中的任何样式元素:

考虑Shadow DOM的样式配置的屏幕截图

Step by Step 一步步

The first thing you will need to do is find an instance of the element you want to style, in this case I created a new, empty, file with the text //TODO: is too subtle . 您需要做的第一件事是找到要设置样式的元素的实例,在这种情况下,我创建了一个新的空文件,文本为//TODO: is too subtle

  1. You now need to find the appropriate selector for the word TODO , simply place your cursor in between the letters of the word TODO and press Ctrl Alt Shift P or select Editor: Log Cursor Scope from the command palette . 您现在需要为单词TODO找到合适的选择器,只需将光标放在单词TODO的字母之间,然后按Ctrl Alt Shift P或从命令面板中选择Editor: Log Cursor Scope
  2. The selectors that apply to that location are listed from the least specific at the top to the most specific at the bottom, in this case you want the most specific selector at the bottom, go ahead and copy that into your clipboard. 应用于该位置的选择器从顶部的最不具体到底部最具体的列表中列出,在这种情况下,您需要底部最具体的选择器,然后将其复制到剪贴板中。
  3. Next you need to open your personal stylesheet, you can do this by selecting "Edit" and then "Stylesheet...", you can also choose Application: Open Your Stylesheet from the command palette. 接下来,您需要打开个人样式表,可以选择“编辑”,然后选择“样式表...”,也可以从命令面板中选择“ Application: Open Your Stylesheet ”。
  4. Scroll to the bottom of the Stylesheet and paste in your selector from Step 2, you will need to add a period (full-stop) at the beginning to make this a valid selector. 滚动到样式表的底部并粘贴到步骤2中的选择器中,您需要在开头添加句点(句号)以使其成为有效的选择器。
  5. Go ahead and add your preferred styling such your VIM style preference: 继续添加您喜欢的样式,例如您的VIM样式首选项:
    atom-text-editor::shadow .type.class.todo {
      background-color: yellow;
      color: black;
      font-style: normal;
    }
  1. Finally save your stylesheet and switch back to your test document to see the resulting changes. 最后保存样式表并切换回测试文档以查看生成的更改。

Thanks to zypro for pointing out that my original answer didn't account for the use of the Shadow DOM in recent versions of Atom . 感谢zypro指出我的原始答案没有说明在最新版本的Atom中使用Shadow DOM

Update: At some point, Atom got rid of the Shadow DOM. 更新:在某些时候,Atom摆脱了Shadow DOM。 I'm using version 1.34.0 which takes the following entry in the above-mentioned stylesheet: 我正在使用版本1.34.0,它在上面提到的样式表中输入以下内容:

atom-text-editor.editor .syntax--type.syntax--class.syntax--todo {
    background-color: yellow;
    color: black;
    font-style: normal;
}

Also, for Python (and some other languages) you will need to uncheck "Use Tree Sitter Parsers" in the Core settings. 此外,对于Python(和其他一些语言),您需要取消选中Core设置中的“Use Tree Sitter Parsers”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM