注释标记
去符号,但将作为代码注释的快捷书签,带有可配置的特殊字符。
详情
安装
- 总数 755
- Win 490
- Mac 123
- Linux 142
8月6日 | 8月5日 | 8月4日 | 8月3日 | 8月2日 | 8月1日 | 7月31日 | 7月30日 | 7月29日 | 7月28日 | 7月27日 | 7月26日 | 7月25日 | 7月24日 | 7月23日 | 7月22日 | 7月21日 | 7月20日 | 7月19日 | 7月18日 | 7月17日 | 7月16日 | 7月15日 | 7月14日 | 7月13日 | 7月12日 | 7月11日 | 7月10日 | 7月9日 | 7月8日 | 7月7日 | 7月6日 | 7月5日 | 7月4日 | 7月3日 | 7月2日 | 7月1日 | 6月30日 | 6月29日 | 6月28日 | 6月27日 | 6月26日 | 6月25日 | 6月24日 | 6月23日 | 6月22日 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 1 |
Mac | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
读我
注释标记
使用注释和特殊字符简单地设置书签或章节标题。
安装后可能需要重新启动Sublime Text。
注释标记在以下示例代码(使用Sublime Text Find)中被突出显示
运行转到注释标记
命令(见下面的用法),将显示下面的可搜索快速面板,可带您到所选注释。
示例
def my_function():
retun 'hello world'
# > Main
def main():
my_function()
# >> Main trigger
if __name__ == '__main__':
main()
在上面的Python代码中,两个标记或部分通过在注释中使用>
字符设置(Main
和Main trigger
)。
>
字符的数量定义了部分的级别,类似于markdown文件中的标题哈希。
用法
- 命令面板:
转到注释标记
- 默认没有设置键盘快捷键。
- 要设置用户键盘快捷键,请转到
Sublime Text
菜单,然后选择首选项
>包设置
>注释标记
>键盘快捷键
- 您将看到左边是示例,右边是您的用户键盘快捷键配置文件。您可以随意复制粘贴。
- 要设置用户键盘快捷键,请转到
尾部注释字符
- 某些语法(例如
C
或HTML
)使用定界字符作为注释,而不是使用单个字符或符号加行结束。- 例如
/* C中的注释 */
。这里,结尾的*/
就是所说的“尾部注释字符”。
- 例如
- 默认情况下,
注释标记
包括尾部注释字符作为注释标记的一部分,并在命令面板中显示它们。 - 或者,可以移除尾部注释标记。
- 要启用此功能,更改设置
trim_trailing_comment_chars
的值到true
(默认为 false)。见下面的配置。- 默认情况下被移除的尾部字符以及特定范围内的配置也可以调整。
设计
目标
- 提供一种简单、有效且灵活的方法来创建、搜索和导航文件中的任意“书签”。
- 使过程简单、轻量级,本质上与编辑器无关。
- 使用一个简单但可配置且希望性能良好的插件。
此插件类似于 注释表
(见Package Control 上的页面)。
差异:
- 功能更简单,代码库也较简单(希望用户更容易修改)
- 使用
python 3.8
,因此仅与Sublime Text v4
兼容
- 使用
- 更可配置(我认为)
- 更快(据我所知)
- 具体来说,我指的是从运行
转到注释标记
命令到看到“书签”快速面板(以及注释表
中的等效功能)的时间。 - 如果这个插件更快,可能是因为以下原因
- 正则表达式模式是在插件加载时准备好,而不是在运行命令时
- 插件相对较小
- 使用
python 3.8
和f-strings
,这可能会提供明显的性能提升。
- 具体来说,我指的是从运行
配置
- 前往
首选项
>包设置
>注释标记
>设置
,这将打开左侧的默认设置和右侧的定制设置。- 设置
json
文件中的大量注释应该提供足够的指导。
- 设置
当前默认设置
{
// Restarting Sublime will probably be necessary for settings to take effect
// The command "Comment Marks: Reload Settings" (run from the command palette)
// should apply any changes to the settings without needing to restart.
// If that does not work, restarting will be a more reliable means of doing so.
// > look ... there are Comment Marks in here :)
// > Basic Visual Settings
// Character to use in comments for creating Comment Marks
// Use repeats of this character to create Comment Marks of increasingly "lower levels"
// like in markdown
"default_level_char": ">",
// Control the formatting of Comment Marks in the Command Palette
// Numeric keys signify what level of Comment Mark the formatting applies to, or
// more specifically, the number of "default_level_char" characters
// that have been repeated.
// The string value is what will replace the level_chars in the quick panel ...
// ... note the spaces which create indentation in the Command Palette.
"level_char_format_sub": {
"1": "",
"2": " - ",
"3": " -- ",
"4": " -- ",
"5": " -- ",
"6": " -- ",
},
// >> Scope specific comment mark character (like level_char above)
// Custom level char for specific scopes, if you want to use a different
// character in particular scopes (so it looks better or clearer, for instance).
// To find the scope of a file, hit CTRL+SHIFT+P, and see the top line, or
// in control panel, run `view.syntax().scope`
"level_chars": {
// "source.python": ">",
// "source.c": ">"
},
// >> Trimming trailing comments (for languages like CSS, HTML, C)
// Whether to trim the trailing characters of a comment (such as */ in CSS)
// Default is false, as somewhat experimental.
// Feel tree to turn on, but if there are problems with this, you can turn it off
"trim_trailing_comment_chars": true,
// What trailing characters to trim for specific scopes/syntaxes (such as */ in CSS).
// These are searched for at the end of every comment mark and stripped if found.
// Default characters are defined in another setting below.
// SO YOU DO NOT NEED TO TOUCH THIS SETTING.
// But if a specific syntax isn't covered by the default settings,
// you can provide the specific trailing characters below for the specific syntax/scope.
// To find the scope of a file, hit CTRL+SHIFT+P, and see the top line, or
// in the control panel, run `view.syntax().scope`.
// You must provide a list of strings, even if providing only a single string.
"scope_comment_trailing_chars": {
// "source.css": ["*/"]
},
// Default characters used as a fallback when no scope-specific characters
// are defined above.
// Each one is searched, one after the other, using a regex OR operator ("|")
// Relying on these is the intended behaviour, YOU DO NOT NEED TO PROVIDE
// SCOPE-SPECIFIC CHARACTERS ABOVE.
// Feel free to adjust or augment this list as you see fit, though you
// might alter the behaviour of the plugin by doing so.
// Must provide a list of strings, even if only one string.
"default_scope_comment_trailing_chars": ["*/", "-->"],
// > Customising the detection of comments
// >> Introduction (rant)
// The plubin finds Comment Marks as follows:
// 1. Uses regex patterns that ...
// 2. Search for lines that start with some combination of whitespace and comment
// characters
// 3. And also generally search for multiple alternative comment characters
// 4. Then, the pattern searches for the level character defined here (eg, ">")
// 5. And finally everything that follows (ie, the "heading" you've written)
// As programming languages have different syntaxes for comments, this plugin's
// default settings define multiple comment characters which are searched as alternatives.
// This works well most of the time, but maybe something is off for a particular syntax
// or you use it in a particular way.
// The settings below allow you to manipulate what characters are searched for
// within files of a particular syntax/scope.
// These characters will then be placed into a larger regex pattern
// (to take care of whitespace) etc.
// If you want, with "custom_comment_start_patterns", you can set the full regex for
// what defines a comment line in a particular syntax/scope,
// where the plugin will add the rest of the needed regex
// for searching for the headings of the comment marks and the level characters (">") etc.
// >> Defining comment characters
// If the default list of comment characters doesn't cover a syntax that
// you're working with (or there's a bug), you can specify the comment character
// for a particular syntax or scope directly here.
// These comment characters are put together into a larger pattern that
// presumes these characters can occur 1 or more times (using regex `+`) ...
// ... see the `source.python` example in custom_comment_start_patterns
// below for what this pattern looks like for python.
// When a file's scope is not here, default characters (defined below) are used instead
// where the first character/sequence found is used.
// Must provide a list of strings, even if only one string.
"scope_comment_chars": {
"source.python": ["#"],
"source.json.sublime.keymap": ["/"]
},
// Default characters used as the fallback when no scope-specific characters
// are defined above.
// There is no need to specify scope-specific characters, relying on these
// default characters is the intended functionality of the plugin.
// You really shouldn't need to alter these, but just in case, you can.
// Doing so may break the plugin though!
// Must provide a list of strings, even if only one string.
"default_scope_comment_chars": ["#", "/", "/*", "%", "<!--", "-"],
// >> Comment regex pattern override
// Provide specific regex patterns for detecting comments for specific scopes.
// REQUIRES KNOWING REGEX.
// These patterns will COMPLETELY OVERRIDE those automatically generated from
// the characters in scope_comment_chars.
// This setting is available if it's necessary to rectify the default behaviour
// either because of a bug, a special need, or a syntax that has not been accounted for.
// Also, it will result in a simpler regex pattern for any scope provided for, which
// could be somewhat more performant (though probably not noticeably).
// A valid example for python is provided for demonstration.
// Must provide a list of strings, even if only one string.
// WARNING ... these patterns are not interpretted as python raw strings, so to use the
// the backslash character ("\") in regex, you'll have to escape it with the python
// escape character, which is the same ("\").
// EG, to match an asterisk with regex requires escaping it ("\*") as the asterisk
// is an operator in regex. BUT, because python interprets the backslash as an escape
// character, it also needs to be escaped ("\\") resulting in "\\*" to match an asterisk.
// Absurdly, to match a backslash in regex requires "\\", ie an escaped escape chararacter,
// and to do it here with a python string requires escaping both of those backslashes,
// ie "\\\\".
"custom_comment_start_patterns": {
"source.python": ["^[ \t]*#+"]
},
}
变更日志
0.1.11
- 从命令面板条目中过滤尾部注释字符(如
CSS
中)- 仅用于在命令面板中显示。
- 作为可选项,当前默认设置为关闭(false)。
- 将设置重新组织为更逻辑的顺序
- 使设置的运作方式更加“模块化”
- 将默认设置与范围特定的设置分开
- 允许范围特定的层级字符和注释字符设置相互独立。当参数(层级字符或注释字符)没有为同一范围提供设置时,任何范围特定的设置(任意一个参数)将简单地采用默认值。