我想做一些类似Textmate技巧的事情,这样当我在 Python 中编写代码时,尾随空格总是会以某种方式突出显示——这样更容易立即更正它,其他编辑器(如 Emacs)可以做到这一点。
不幸的是,该帖子之后的讨论似乎表明这很难做到。对我来说,invalid.trailing-whitespace
遵循此提示后,范围选择器甚至在首选项中都不可见。有没有其他人在这方面取得过任何成功?
我不知道如何突出显示尾随空格,但您可以通过转到
捆绑 -> 文本 -> 转换/剥离 -> 删除文档中的尾随空格
此外,因为 textmate 具有 emacs 绑定,您可以像在 emacs 中那样做。
此代码有效(但不带注释):
{ scopeName = 'source.whitespace';
patterns = (
{ name = 'source.invalid.trailing-whitespace';
match = '(\s+)$';
captures = { 1 = { name = 'invalid.trailing-whitespace'; }; };
},
);
}
PS:我已将“source”更改为“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 语言定义中添加一个“包含”,其中:
:
patterns = (
{ name = 'comment.line.number-sign.python';
:
转为:
:
patterns = (
{ include = 'source.whitespace'; },
{ name = 'comment.line.number-sign.python';
: