我想做类似于这个Textmate提示的事情,这样当我编写Python代码时,尾随空格总是以某种方式突出显示-这使得立即纠正更容易,并且其他编辑器如Emacs也可以实现。
不幸的是,在该文章之后的讨论中,似乎难以实现。对我而言,即使按照此提示操作,invalid.trailing-whitespace
范围选择器在首选项中也不可见。是否有其他人成功实现过?
{ scopeName = 'source.whitespace';
patterns = (
{ name = 'source.invalid.trailing-whitespace';
match = '(\s+)$';
captures = { 1 = { name = 'invalid.trailing-whitespace'; }; };
},
);
}
PS:我已将“源”更改为“source.whitespace”
对于Python语法中的注释更改:
{ name = 'comment.line.number-sign.python';
match = '(#).*$\n?';
captures = { 1 = { name = 'punctuation.definition.comment.python'; }; };
},
在:
{ name = 'comment.line.number-sign.python';
match = '(#).*?(\s*)$\n?';
captures = {
1 = { name = 'punctuation.definition.comment.python'; };
2 = { name = 'invalid.trailing-whitespace'; };
};
},
在Python语言定义中,您需要添加一个“include”,其中:
:
patterns = (
{ name = 'comment.line.number-sign.python';
:
Turns to:
:
patterns = (
{ include = 'source.whitespace'; },
{ name = 'comment.line.number-sign.python';
: